Fix a crash caused by empty keyboard focus
authorJjgod Jiang <gzjjgod@gmail.com>
Tue, 20 Apr 2010 07:16:42 -0700
changeset 4437 25e45611fa3d
parent 4436 d3c193100522
child 4439 ab63fdcf66af
Fix a crash caused by empty keyboard focus --- src/events/SDL_keyboard.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
src/events/SDL_keyboard.c
--- a/src/events/SDL_keyboard.c	Thu Apr 15 22:27:50 2010 -0700
+++ b/src/events/SDL_keyboard.c	Tue Apr 20 07:16:42 2010 -0700
@@ -813,7 +813,7 @@
         event.key.keysym.sym = keyboard->keymap[scancode];
         event.key.keysym.mod = modstate;
         event.key.keysym.unicode = 0;
-        event.key.windowID = keyboard->focus->id;
+        event.key.windowID = keyboard->focus ? keyboard->focus->id : 0;
         posted = (SDL_PushEvent(&event) > 0);
     }
     return (posted);
@@ -837,7 +837,7 @@
         event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
         event.text.which = (Uint8) index;
         SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
-        event.text.windowID = keyboard->focus->id;
+        event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
         posted = (SDL_PushEvent(&event) > 0);
     }
     return (posted);