Skip to content

Commit

Permalink
Fixed bug 3770 - XStoreColor returns zero on failure
Browse files Browse the repository at this point in the history
Thorsten Otto

The fix done in http://hg.libsdl.org/SDL/rev/3665bc284271 is wrong. The current code returns -1 if the calls *succeeds*, and does not call XSync(). The outcome of this is that the whole screen turns black when trying to open a 640x480x8 window on a true-color display (short example attached). I suggest to add the attached patch to fix this (yes i know that the 1.2 branch is obsolete, but the faulty patch causes really bad behaviour for a very common scenario).
  • Loading branch information
slouken committed Aug 28, 2017
1 parent 095451b commit 8c86953
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -1462,7 +1462,7 @@ int X11_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)

int X11_SetGammaRamp(_THIS, Uint16 *ramp)
{
int i, ncolors;
int i, result, ncolors;
XColor xcmap[256];

/* See if actually setting the gamma is supported */
Expand All @@ -1481,12 +1481,13 @@ int X11_SetGammaRamp(_THIS, Uint16 *ramp)
xcmap[i].blue = ramp[2*256+c];
xcmap[i].flags = (DoRed|DoGreen|DoBlue);
}
if ( XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors) != 0 ) {
result = 0;
if ( XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors) == False ) {
SDL_SetError("Setting gamma correction failed");
return(-1);
result = -1;
}
XSync(GFX_Display, False);
return(0);
return result;
}

/* Note: If we are terminated, this could be called in the middle of
Expand Down

0 comments on commit 8c86953

Please sign in to comment.