Fixed bug 1238 - SDL_SetKeyboardFocus may send events to already destroyed 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
This commit is contained in:
parent
41b2fc0189
commit
185bcb6114
1 changed files with 11 additions and 3 deletions
|
@ -1932,6 +1932,17 @@ 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) {
|
||||
|
@ -1939,9 +1950,6 @@ SDL_DestroyWindow(SDL_Window * window)
|
|||
}
|
||||
}
|
||||
|
||||
/* Restore video mode, etc. */
|
||||
SDL_HideWindow(window);
|
||||
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
SDL_FreeSurface(window->surface);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue