Android: add mutex protection to onNativeOrientationChanged
authorSylvain Becker <sylvain.becker@gmail.com>
Wed, 16 Jan 2019 10:48:28 +0100
changeset 12553faaec3975dbd
parent 12552 6bc8c73ab0fe
child 12554 66498ac4cff7
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
     1.1 --- a/src/core/android/SDL_android.c	Wed Jan 16 10:31:51 2019 +0100
     1.2 +++ b/src/core/android/SDL_android.c	Wed Jan 16 10:48:28 2019 +0100
     1.3 @@ -700,11 +700,15 @@
     1.4                                      JNIEnv *env, jclass jcls,
     1.5                                      jint orientation)
     1.6  {
     1.7 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
     1.8 -    if (_this) {
     1.9 +    SDL_LockMutex(Android_ActivityMutex);
    1.10 +
    1.11 +    if (Android_Window)
    1.12 +    {
    1.13          SDL_VideoDisplay *display = SDL_GetDisplay(0);
    1.14          SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation);
    1.15      }
    1.16 +
    1.17 +    SDL_UnlockMutex(Android_ActivityMutex);
    1.18  }
    1.19  
    1.20  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeAddTouch)(