Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug 1238 - SDL_SetKeyboardFocus may send events to already dest…

…royed windows

bastien.bouclet@gmail.com 2011-06-26 02:15:36 PDT

SDL_Keyboard::focus does not seem to be reset when the window that has focus is
destroyed, resulting in the following crash :

#0  X11_SetWindowGammaRamp (_this=0x8ed9cb0, window=0x91f25c0, ramp=0x0) at
src/video/x11/SDL_x11window.c:948
#1  0x001bd15e in SDL_OnWindowFocusLost (window=0x91f25c0) at
src/video/SDL_video.c:1900
#2  0x00168a2e in SDL_SendWindowEvent (window=0x91f25c0, windowevent=<value
optimized out>, data1=0, data2=0)
    at src/events/SDL_windowevents.c:157
#3  0x00166454 in SDL_SetKeyboardFocus (window=0x9678a08) at
src/events/SDL_keyboard.c:612
  • Loading branch information
slouken committed Jan 14, 2012
1 parent 52565f5 commit 5b7a8f671394921829b80e96b483ee1e9da795fe
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/video/SDL_video.c
@@ -1932,16 +1932,24 @@ SDL_DestroyWindow(SDL_Window * window)

CHECK_WINDOW_MAGIC(window, );

/* Restore video mode, etc. */
SDL_HideWindow(window);

/* Make sure this window no longer has focus */
if (SDL_GetKeyboardFocus() == window) {
SDL_SetKeyboardFocus(NULL);
}
if (SDL_GetMouseFocus() == window) {
SDL_SetMouseFocus(NULL);
}

/* make no context current if this is the current context window. */
if (window->flags & SDL_WINDOW_OPENGL) {
if (_this->current_glwin == window) {
SDL_GL_MakeCurrent(NULL, NULL);
}
}

/* Restore video mode, etc. */
SDL_HideWindow(window);

if (window->surface) {
window->surface->flags &= ~SDL_DONTFREE;
SDL_FreeSurface(window->surface);

0 comments on commit 5b7a8f6

Please sign in to comment.