summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java/org
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2024-04-13 01:40:30 +0200
committerGitHub <noreply@github.com>2024-04-13 01:40:30 +0200
commitb623a360059c008ccc5f51b475fc800ebf60a597 (patch)
tree680116a4f00332404fbfc33eb90ae17304a9bbaa /Source/Android/app/src/main/java/org
parentd58c998d6d865ed4f5aa67b4a6a8b9318bb564db (diff)
parent9ca9d073df98b0bc976eac68c3d708fec57f3389 (diff)
Merge pull request #12688 from JosJuice/android-alert-synchronize
Android: Fix race condition in displayAlertMsg
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, 8 insertions, 13 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 8abec6927b..43880bd0ba 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
@@ -21,6 +21,7 @@ import org.dolphinemu.dolphinemu.utils.Log;
import java.lang.ref.WeakReference;
import java.util.LinkedHashMap;
+import java.util.concurrent.Semaphore;
/**
* Class which contains methods that interact
@@ -28,7 +29,7 @@ import java.util.LinkedHashMap;
*/
public final class NativeLibrary
{
- private static final Object sAlertMessageLock = new Object();
+ private static final Semaphore sAlertMessageSemaphore = new Semaphore(0);
private static boolean sIsShowingAlertMessage = false;
private static WeakReference<EmulationActivity> sEmulationActivity = new WeakReference<>(null);
@@ -491,15 +492,12 @@ public final class NativeLibrary
});
// Wait for the lock to notify that it is complete.
- synchronized (sAlertMessageLock)
+ try
+ {
+ sAlertMessageSemaphore.acquire();
+ }
+ catch (InterruptedException ignored)
{
- try
- {
- sAlertMessageLock.wait();
- }
- catch (Exception ignored)
- {
- }
}
if (yesNo)
@@ -519,10 +517,7 @@ public final class NativeLibrary
public static void NotifyAlertMessageLock()
{
- synchronized (sAlertMessageLock)
- {
- sAlertMessageLock.notify();
- }
+ sAlertMessageSemaphore.release();
}
public static void setEmulationActivity(EmulationActivity emulationActivity)