From cfdddbf043d198ceda7d708a5d18dfed18ebda6e Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 28 Mar 2021 12:26:08 +1000 Subject: [PATCH] Android: Use global reference to EmulationActivity Fixes crash when loading input profile while running. --- android/app/src/cpp/android_host_interface.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/app/src/cpp/android_host_interface.cpp b/android/app/src/cpp/android_host_interface.cpp index ab986b717..80a9c7be7 100644 --- a/android/app/src/cpp/android_host_interface.cpp +++ b/android/app/src/cpp/android_host_interface.cpp @@ -456,6 +456,9 @@ void AndroidHostInterface::EmulationThreadEntryPoint(JNIEnv* env, jobject emulat return; } + emulation_activity = env->NewGlobalRef(emulation_activity); + Assert(emulation_activity != nullptr); + { std::unique_lock lock(m_mutex); m_emulation_thread_running.store(true); @@ -499,6 +502,7 @@ void AndroidHostInterface::EmulationThreadEntryPoint(JNIEnv* env, jobject emulat } env->CallVoidMethod(emulation_activity, s_EmulationActivity_method_onEmulationStopped); + env->DeleteGlobalRef(emulation_activity); } void AndroidHostInterface::EmulationThreadLoop(JNIEnv* env)