diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 29a78115d..9806e8912 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -630,7 +630,6 @@ void WIN_SetWindowTitle(_THIS, SDL_Window *window) int WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) { - int retVal = 0; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) HWND hwnd = window->driverdata->hwnd; HICON hicon = NULL; @@ -639,6 +638,7 @@ int WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) BITMAPINFOHEADER *bmi; Uint8 *dst; SDL_bool isstack; + int retval = 0; /* Create temporary buffer for ICONIMAGE structure */ SDL_COMPILE_TIME_ASSERT(WIN_SetWindowIcon_uses_BITMAPINFOHEADER_to_prepare_an_ICONIMAGE, sizeof(BITMAPINFOHEADER) == 40); @@ -679,8 +679,7 @@ int WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) SDL_small_free(icon_bmp, isstack); if (hicon == NULL) { - SDL_SetError("SetWindowIcon() failed, error %08X", (unsigned int)GetLastError()); - retVal = -1; + retval = SDL_SetError("SetWindowIcon() failed, error %08X", (unsigned int)GetLastError()); } /* Set the icon for the window */ @@ -688,10 +687,10 @@ int WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) /* Set the icon in the task manager (should we do this?) */ SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon); + return retval; #else - retVal = SDL_Unsupported(); + return SDL_Unsupported(); #endif - return retVal; } void WIN_SetWindowPosition(_THIS, SDL_Window *window) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index ed47474ba..4274d8acc 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -753,14 +753,13 @@ int X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) SDL_WindowData *data = window->driverdata; Display *display = data->videodata->display; Atom _NET_WM_ICON = data->videodata->_NET_WM_ICON; - int retVal = 0; + int rc = 0; int (*prevHandler)(Display *, XErrorEvent *) = NULL; if (icon) { + int x, y; int propsize; long *propdata; - - int x, y; Uint32 *src; long *dst; @@ -772,6 +771,7 @@ int X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) if (!propdata) { return SDL_OutOfMemory(); } + X11_XSync(display, False); prevHandler = X11_XSetErrorHandler(X11_CatchAnyError); @@ -792,9 +792,8 @@ int X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) SDL_free(propdata); if (caught_x11_error) { - retVal = SDL_SetError("An error occurred while trying to set the window's icon"); + rc = SDL_SetError("An error occurred while trying to set the window's icon"); } - } X11_XFlush(display); @@ -804,7 +803,7 @@ int X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) caught_x11_error = SDL_FALSE; } - return retVal; + return rc; } void X11_SetWindowPosition(_THIS, SDL_Window *window)