2
0
Эх сурвалжийг харах

Only let the Java activity finish be requested once.

Lasse Öörni 12 жил өмнө
parent
commit
c814081a7a

+ 8 - 1
Source/Engine/Engine/Engine.cpp

@@ -93,6 +93,9 @@ Engine::Engine(Context* context) :
     #endif
     #endif
     autoExit_(true),
     autoExit_(true),
     initialized_(false),
     initialized_(false),
+#ifdef ANDROID
+    exitRequested_(false),
+#endif
     exiting_(false),
     exiting_(false),
     headless_(false),
     headless_(false),
     audioPaused_(false)
     audioPaused_(false)
@@ -416,7 +419,11 @@ void Engine::Exit()
     // On iOS it's not legal for the application to exit on its own, instead it will be minimized with the home key
     // On iOS it's not legal for the application to exit on its own, instead it will be minimized with the home key
 #elif defined(ANDROID)
 #elif defined(ANDROID)
     // On Android we request the Java activity to finish itself
     // On Android we request the Java activity to finish itself
-    Android_JNI_FinishActivity();
+    if (!exitRequested_)
+    {
+        Android_JNI_FinishActivity();
+        exitRequested_ = true;
+    }
 #else
 #else
     DoExit();
     DoExit();
 #endif
 #endif

+ 4 - 0
Source/Engine/Engine/Engine.h

@@ -122,6 +122,10 @@ private:
     bool autoExit_;
     bool autoExit_;
     /// Initialized flag.
     /// Initialized flag.
     bool initialized_;
     bool initialized_;
+#ifdef ANDROID
+    /// Exit requested flag for preventing multiple finish activity requests.
+    bool exitRequested_;
+#endif
     /// Exiting flag.
     /// Exiting flag.
     bool exiting_;
     bool exiting_;
     /// Headless mode flag.
     /// Headless mode flag.