summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java/org
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-11-06 22:35:37 +0100
committerJosJuice <josjuice@gmail.com>2020-11-09 10:38:50 +0100
commitd982afd1eff1b7ce8c8c8c969f49d12b3b763098 (patch)
tree22f6b29b7b0fc017aa98649f272dc3a9546fb273 /Source/Android/app/src/main/java/org
parentee52f465b10ef8541c642522f053d273492baf8f (diff)
Android: Fix alert messages when EmulationActivity is being destroyed
The previous commit made this easy to reproduce when launching an invalid disc image with the phone rotated incorrectly.
Diffstat (limited to 'Source/Android/app/src/main/java/org')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
index 0c35a35da0..486e5bab7d 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
@@ -12,6 +12,8 @@ import android.util.DisplayMetrics;
import android.view.Surface;
import android.widget.Toast;
+import androidx.fragment.app.FragmentManager;
+
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.dialogs.AlertMessage;
import org.dolphinemu.dolphinemu.utils.CompressCallback;
@@ -508,9 +510,22 @@ public final class NativeLibrary
{
sIsShowingAlertMessage = true;
- emulationActivity.runOnUiThread(
- () -> AlertMessage.newInstance(caption, text, yesNo, isWarning)
- .show(emulationActivity.getSupportFragmentManager(), "AlertMessage"));
+ emulationActivity.runOnUiThread(() ->
+ {
+ FragmentManager fragmentManager = emulationActivity.getSupportFragmentManager();
+ if (fragmentManager.isStateSaved())
+ {
+ // The activity is being destroyed, so we can't use it to display an AlertMessage.
+ // Fall back to a toast.
+ Toast.makeText(emulationActivity, text, Toast.LENGTH_LONG).show();
+ NotifyAlertMessageLock();
+ }
+ else
+ {
+ AlertMessage.newInstance(caption, text, yesNo, isWarning)
+ .show(fragmentManager, "AlertMessage");
+ }
+ });
// Wait for the lock to notify that it is complete.
synchronized (sAlertMessageLock)