From 5aa094a5b2be689439ad09d2b848bd91f3140751 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 18 Sep 2010 18:31:01 -0700 Subject: [PATCH] Fixed crash on systems that don't have StopTextInput --- src/events/SDL_keyboard.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 06fba0eb3..b75aea3d7 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -612,11 +612,14 @@ SDL_SetKeyboardFocus(SDL_Window * window) if (keyboard->focus && keyboard->focus != window) { SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); - - //Ensures IME compositions are committed - if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { - SDL_GetVideoDevice()->StopTextInput(SDL_GetVideoDevice()); - } + + /* Ensures IME compositions are committed */ + if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { + SDL_VideoDevice *video = SDL_GetVideoDevice(); + if (video && video->StopTextInput) { + video->StopTextInput(video); + } + } } keyboard->focus = window; @@ -626,7 +629,10 @@ SDL_SetKeyboardFocus(SDL_Window * window) 0, 0); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { - SDL_StartTextInput(); + SDL_VideoDevice *video = SDL_GetVideoDevice(); + if (video && video->StartTextInput) { + video->StartTextInput(video); + } } } }