From 8a19ff3e2d8ecc45ab349442640790156bbbfaf8 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Wed, 16 Jan 2019 10:48:28 +0100 Subject: [PATCH] Android: add mutex protection to onNativeOrientationChanged it's possible receive try to send an event between the check first for SDL_GetVideoDevice and SDL_VideoQuit is called --- src/core/android/SDL_android.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 2136c1b1b..eeec7c49f 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -700,11 +700,15 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( JNIEnv *env, jclass jcls, jint orientation) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this) { + SDL_LockMutex(Android_ActivityMutex); + + if (Android_Window) + { SDL_VideoDisplay *display = SDL_GetDisplay(0); SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation); } + + SDL_UnlockMutex(Android_ActivityMutex); } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeAddTouch)(