@@ -1417,7 +1417,6 @@ surf_set_colorkey(pgSurfaceObject *self, PyObject *args)
14171417 SDL_Surface * surf = pgSurface_AsSurface (self );
14181418 Uint32 flags = 0 , color = 0 ;
14191419 PyObject * rgba_obj = NULL ;
1420- int result ;
14211420 int hascolor = SDL_FALSE ;
14221421
14231422 if (!PyArg_ParseTuple (args , "|Oi" , & rgba_obj , & flags )) {
@@ -1436,22 +1435,23 @@ surf_set_colorkey(pgSurfaceObject *self, PyObject *args)
14361435 }
14371436
14381437 pgSurface_Prep (self );
1439- result = 0 ;
1438+ bool success = true ;
14401439 if (hascolor && PG_SURF_BytesPerPixel (surf ) == 1 ) {
14411440 /* For an indexed surface, remove the previous colorkey first.
14421441 */
1443- result = SDL_SetColorKey (surf , SDL_FALSE , color );
1442+ success = PG_SetSurfaceColorKey (surf , SDL_FALSE , color );
14441443 }
1445- if (result == 0 && hascolor ) {
1446- result = SDL_SetSurfaceRLE (
1447- surf , (flags & PGS_RLEACCEL ) ? SDL_TRUE : SDL_FALSE );
1444+ if (success && hascolor ) {
1445+ success =
1446+ SDL_SetSurfaceRLE (
1447+ surf , (flags & PGS_RLEACCEL ) ? SDL_TRUE : SDL_FALSE ) == 0 ;
14481448 }
1449- if (result == 0 ) {
1450- result = SDL_SetColorKey (surf , hascolor , color );
1449+ if (success ) {
1450+ success = PG_SetSurfaceColorKey (surf , hascolor , color );
14511451 }
14521452 pgSurface_Unprep (self );
14531453
1454- if (result == -1 ) {
1454+ if (! success ) {
14551455 return RAISE (pgExc_SDLError , SDL_GetError ());
14561456 }
14571457
@@ -1814,7 +1814,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
18141814
18151815 if (has_colorkey ) {
18161816 colorkey = SDL_MapSurfaceRGBA (newsurf , key_r , key_g , key_b , key_a );
1817- if (SDL_SetColorKey (newsurf , SDL_TRUE , colorkey ) != 0 ) {
1817+ if (! PG_SetSurfaceColorKey (newsurf , SDL_TRUE , colorkey )) {
18181818 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
18191819 SDL_FreeSurface (newsurf );
18201820 return NULL ;
@@ -1977,7 +1977,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
19771977
19781978 if (has_colorkey ) {
19791979 colorkey = SDL_MapRGBA (newsurf -> format , key_r , key_g , key_b , key_a );
1980- if (SDL_SetColorKey (newsurf , SDL_TRUE , colorkey ) != 0 ) {
1980+ if (! PG_SetSurfaceColorKey (newsurf , SDL_TRUE , colorkey )) {
19811981 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
19821982 SDL_FreeSurface (newsurf );
19831983 return NULL ;
@@ -3259,7 +3259,7 @@ surf_subsurface(PyObject *self, PyObject *args)
32593259 }
32603260 if (SDL_HasColorKey (surf )) {
32613261 SDL_GetColorKey (surf , & colorkey );
3262- if (SDL_SetColorKey (sub , SDL_TRUE , colorkey ) != 0 ) {
3262+ if (! PG_SetSurfaceColorKey (sub , SDL_TRUE , colorkey )) {
32633263 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
32643264 SDL_FreeSurface (sub );
32653265 return NULL ;
0 commit comments