We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1238

Summary: SDL_SetKeyboardFocus may send events to already destroyed windows
Product: SDL Reporter: bastien.bouclet
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: Linux   

Description bastien.bouclet 2011-06-26 02:15:36 UTC
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
#4  0x001c9547 in X11_DispatchEvent (_this=0x8ed9cb0) at src/video/x11/SDL_x11events.c:190
#5  X11_PumpEvents (_this=0x8ed9cb0) at src/video/x11/SDL_x11events.c:542
#6  0x00163f24 in SDL_PumpEvents () at src/events/SDL_events.c:302
#7  0x0016438a in SDL_WaitEventTimeout (event=0xbfffe15c, timeout=0) at src/events/SDL_events.c:335
#8  0x00164465 in SDL_PollEvent (event=0xbfffe15c) at src/events/SDL_events.c:317
#9  0x089975d3 in SdlEventSource::pollEvent (this=0x8ec2a58, event=...) at backends/events/sdl/sdl-events.cpp:209

SDL_SetKeyboardFocus looks like it can call SDL_SendWindowEvent for an already destroyed window.
Comment 1 Sam Lantinga 2012-01-13 22:38:50 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/b1a71f8189a6