Fixed crash on systems that don't have StopTextInput

This commit is contained in:
Sam Lantinga 2010-09-18 18:31:01 -07:00
parent 7fcd8b7560
commit eaca51873a

View file

@ -613,9 +613,12 @@ SDL_SetKeyboardFocus(SDL_Window * window)
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST, SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
0, 0); 0, 0);
//Ensures IME compositions are committed /* Ensures IME compositions are committed */
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_GetVideoDevice()->StopTextInput(SDL_GetVideoDevice()); SDL_VideoDevice *video = SDL_GetVideoDevice();
if (video && video->StopTextInput) {
video->StopTextInput(video);
}
} }
} }
@ -626,7 +629,10 @@ SDL_SetKeyboardFocus(SDL_Window * window)
0, 0); 0, 0);
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_StartTextInput(); SDL_VideoDevice *video = SDL_GetVideoDevice();
if (video && video->StartTextInput) {
video->StartTextInput(video);
}
} }
} }
} }