summaryrefslogtreecommitdiffstats
path: root/platform/android
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2023-04-22 15:34:16 +0200
committerJuan Linietsky <reduzio@gmail.com>2023-04-24 15:13:58 +0200
commita37c30dfc92d98d79c4a315c58ecb5b2adabf97a (patch)
treec0a91be57bf01b77c5b0aa090233c63f9135eab1 /platform/android
parent24cb43a8741c7b10abbbbc77bb6e2bc188662ce0 (diff)
downloadredot-engine-a37c30dfc92d98d79c4a315c58ecb5b2adabf97a.tar.gz
Fix thread IDs.
On Linux, thread IDs were not properly assigned with the current approach. The line: `std::thread new_thread(&Thread::callback, _thread_id_hash(thread.get_id()), p_settings, p_callback, p_user);` does not work because the thread ID is not assigned until the thread starts. This PR changes the behavior to use manually generated thread IDs. Additionally, if a thread is (or may have been created) outside Godot, the method `Thread::attach_external_thread` was added.
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/export/export_plugin.cpp4
-rw-r--r--platform/android/java_godot_lib_jni.cpp2
2 files changed, 4 insertions, 2 deletions
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 0f0132a5d1..f52edf2b61 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -3306,6 +3306,8 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
#ifndef ANDROID_ENABLED
quit_request.set();
- check_for_changes_thread.wait_to_finish();
+ if (check_for_changes_thread.is_started()) {
+ check_for_changes_thread.wait_to_finish();
+ }
#endif
}
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 1a0087e18d..f32617e674 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -244,7 +244,7 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env,
if (step.get() == 0) {
// Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id,
// but for Godot purposes, the main thread is the one running the game loop
- Main::setup2(Thread::get_caller_id());
+ Main::setup2();
input_handler = new AndroidInputHandler();
step.increment();
return true;