diff --git a/main/main.cpp b/main/main.cpp index f2a01f43801..e94e3626681 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -69,7 +69,6 @@ #include "core/io/file_access_zip.h" #include "core/io/stream_peer_ssl.h" #include "core/io/stream_peer_tcp.h" -#include "core/os/thread.h" #include "main/input_default.h" #include "performance.h" #include "translation.h" @@ -842,7 +841,11 @@ error: return ERR_INVALID_PARAMETER; } -Error Main::setup2() { +Error Main::setup2(Thread::ID p_main_tid_override) { + + if (p_main_tid_override) { + Thread::_main_thread_id = p_main_tid_override; + } OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx); if (init_use_custom_pos) { diff --git a/main/main.h b/main/main.h index f8db0225bf4..2c1d42a163d 100644 --- a/main/main.h +++ b/main/main.h @@ -34,6 +34,7 @@ @author Juan Linietsky */ +#include "core/os/thread.h" #include "error_list.h" #include "typedefs.h" @@ -49,7 +50,7 @@ class Main { public: static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true); - static Error setup2(); + static Error setup2(Thread::ID p_main_tid_override = 0); static bool start(); static bool iteration(); static void cleanup(); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 32b70a60fae..84227c0deca 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1596,11 +1596,7 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) { //export_temp ep.step("Exporting APK", 0); - bool use_adb_over_usb = bool(EDITOR_DEF("android/use_remote_debug_over_adb", true)); - - if (use_adb_over_usb) { - p_flags |= EXPORT_REMOTE_DEBUG_LOCALHOST; - } + p_flags |= EXPORT_REMOTE_DEBUG_LOCALHOST; // Needed for adb reverse String export_to = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport.apk"; Error err = export_project(export_to, true, p_flags); @@ -1649,14 +1645,14 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) { return ERR_CANT_CREATE; } - if (use_adb_over_usb) { + args.clear(); + args.push_back("-s"); + args.push_back(devices[p_device].id); + args.push_back("reverse"); + args.push_back("--remove-all"); + err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); - args.clear(); - args.push_back("-s"); - args.push_back(devices[p_device].id); - args.push_back("reverse"); - args.push_back("--remove-all"); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + if (p_flags & EXPORT_REMOTE_DEBUG) { int dbg_port = (int)EditorSettings::get_singleton()->get("network/debug_port"); args.clear(); @@ -1668,6 +1664,9 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) { err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); print_line("Reverse result: " + itos(rv)); + } + + if (p_flags & EXPORT_DUMB_CLIENT) { int fs_port = EditorSettings::get_singleton()->get("file_server/port"); @@ -1847,7 +1846,6 @@ void register_android_exporter() { //EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/release_keystore",PROPERTY_HINT_GLOBAL_FILE,"*.keystore")); EDITOR_DEF("android/force_system_user", false); EDITOR_DEF("android/timestamping_authority_url", ""); - EDITOR_DEF("android/use_remote_debug_over_adb", false); EDITOR_DEF("android/shutdown_adb_on_exit", true); Ref exporter = Ref(memnew(EditorExportPlatformAndroid)); diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 9123a65b7e5..fd93cb0ead0 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -1001,7 +1001,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job Globals::get_singleton()->add_singleton(Globals::Singleton("JavaClassWrapper", java_class_wrapper)); _initialize_java_modules(); - Main::setup2(); + // 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()); ++step; suspend_mutex->unlock(); input_mutex->unlock();