diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 2c3444df2..74a28da33 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -98,7 +98,7 @@ void Android_PumpEvents_Blocking(SDL_VideoDevice *_this) if (videodata->isPaused) { #ifdef SDL_VIDEO_OPENGL_EGL /* Make sure this is the last thing we do before pausing */ - if (!Android_Window->external_graphics_context) { + if (Android_Window && !Android_Window->external_graphics_context) { SDL_LockMutex(Android_ActivityMutex); android_egl_context_backup(Android_Window); SDL_UnlockMutex(Android_ActivityMutex); @@ -122,7 +122,7 @@ void Android_PumpEvents_Blocking(SDL_VideoDevice *_this) /* Restore the GL Context from here, as this operation is thread dependent */ #ifdef SDL_VIDEO_OPENGL_EGL - if (!Android_Window->external_graphics_context && !SDL_HasEvent(SDL_EVENT_QUIT)) { + if (Android_Window && !Android_Window->external_graphics_context && !SDL_HasEvent(SDL_EVENT_QUIT)) { SDL_LockMutex(Android_ActivityMutex); android_egl_context_restore(Android_Window); SDL_UnlockMutex(Android_ActivityMutex); @@ -130,7 +130,9 @@ void Android_PumpEvents_Blocking(SDL_VideoDevice *_this) #endif /* Make sure SW Keyboard is restored when an app becomes foreground */ - Android_RestoreScreenKeyboardOnResume(_this, Android_Window); + if (Android_Window) { + Android_RestoreScreenKeyboardOnResume(_this, Android_Window); + } SDL_SendAppEvent(SDL_EVENT_DID_ENTER_FOREGROUND); SDL_SendWindowEvent(Android_Window, SDL_EVENT_WINDOW_RESTORED, 0, 0); @@ -168,7 +170,7 @@ void Android_PumpEvents_NonBlocking(SDL_VideoDevice *_this) if (backup_context) { #ifdef SDL_VIDEO_OPENGL_EGL - if (!Android_Window->external_graphics_context) { + if (Android_Window && !Android_Window->external_graphics_context) { SDL_LockMutex(Android_ActivityMutex); android_egl_context_backup(Android_Window); SDL_UnlockMutex(Android_ActivityMutex); @@ -199,7 +201,7 @@ void Android_PumpEvents_NonBlocking(SDL_VideoDevice *_this) #ifdef SDL_VIDEO_OPENGL_EGL /* Restore the GL Context from here, as this operation is thread dependent */ - if (!Android_Window->external_graphics_context && !SDL_HasEvent(SDL_EVENT_QUIT)) { + if (Android_Window && !Android_Window->external_graphics_context && !SDL_HasEvent(SDL_EVENT_QUIT)) { SDL_LockMutex(Android_ActivityMutex); android_egl_context_restore(Android_Window); SDL_UnlockMutex(Android_ActivityMutex); @@ -207,7 +209,9 @@ void Android_PumpEvents_NonBlocking(SDL_VideoDevice *_this) #endif /* Make sure SW Keyboard is restored when an app becomes foreground */ - Android_RestoreScreenKeyboardOnResume(_this, Android_Window); + if (Android_Window) { + Android_RestoreScreenKeyboardOnResume(_this, Android_Window); + } SDL_SendAppEvent(SDL_EVENT_DID_ENTER_FOREGROUND); SDL_SendWindowEvent(Android_Window, SDL_EVENT_WINDOW_RESTORED, 0, 0);