diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 77cb48d9d1..fd34203d67 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -469,11 +469,27 @@ void EditorExportPlatformAndroid::_update_preset_status() { bool has_runnable = EditorExport::get_singleton()->get_runnable_preset_for_platform(this).is_valid(); if (has_runnable) { has_runnable_preset.set(); + _start_check_for_changes_poll_thread(); } else { has_runnable_preset.clear(); + _stop_check_for_changes_poll_thread(); } devices_changed.set(); } + +void EditorExportPlatformAndroid::_start_check_for_changes_poll_thread() { + quit_request.clear(); + if (!check_for_changes_thread.is_started()) { + check_for_changes_thread.start(_check_for_changes_poll_thread, this); + } +} + +void EditorExportPlatformAndroid::_stop_check_for_changes_poll_thread() { + quit_request.set(); + if (check_for_changes_thread.is_started()) { + check_for_changes_thread.wait_to_finish(); + } +} #endif String EditorExportPlatformAndroid::get_project_name(const Ref &p_preset, const String &p_name) const { @@ -4427,7 +4443,6 @@ void EditorExportPlatformAndroid::initialize() { devices_changed.set(); _create_editor_debug_keystore_if_needed(); _update_preset_status(); - check_for_changes_thread.start(_check_for_changes_poll_thread, this); use_scrcpy = EditorSettings::get_singleton()->get_project_metadata("android", "use_scrcpy", false); #else // ANDROID_ENABLED android_editor_gradle_runner = memnew(AndroidEditorGradleRunner); @@ -4437,10 +4452,7 @@ void EditorExportPlatformAndroid::initialize() { EditorExportPlatformAndroid::~EditorExportPlatformAndroid() { #ifndef ANDROID_ENABLED - quit_request.set(); - if (check_for_changes_thread.is_started()) { - check_for_changes_thread.wait_to_finish(); - } + _stop_check_for_changes_poll_thread(); #else if (android_editor_gradle_runner) { memdelete(android_editor_gradle_runner); diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index 527b9e9023..038c7fb236 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -108,6 +108,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { SafeFlag has_runnable_preset; static void _check_for_changes_poll_thread(void *ud); + void _start_check_for_changes_poll_thread(); + void _stop_check_for_changes_poll_thread(); void _update_preset_status(); #else // ANDROID_ENABLED AndroidEditorGradleRunner *android_editor_gradle_runner = nullptr;