diff options
Diffstat (limited to 'editor/editor_file_system.cpp')
-rw-r--r-- | editor/editor_file_system.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index ec1ef8a6bc..8a595be6e6 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1237,10 +1237,23 @@ void EditorFileSystem::_notification(int p_what) { case NOTIFICATION_PROCESS: { if (use_threads) { + /** This hack exists because of the EditorProgress nature + * of processing events recursively. This needs to be rewritten + * at some point entirely, but in the meantime the following + * hack prevents deadlock on import. + */ + + static bool prevent_recursive_process_hack = false; + if (prevent_recursive_process_hack) { + break; + } + + prevent_recursive_process_hack = true; + + bool done_importing = false; + if (scanning_changes) { if (scanning_changes_done) { - scanning_changes = false; - set_process(false); thread_sources.wait_to_finish(); @@ -1251,6 +1264,8 @@ void EditorFileSystem::_notification(int p_what) { } emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); first_scan = false; + scanning_changes = false; // Changed to false here to prevent recursive triggering of scan thread. + done_importing = true; } } else if (!scanning && thread.is_started()) { set_process(false); @@ -1268,10 +1283,12 @@ void EditorFileSystem::_notification(int p_what) { first_scan = false; } - if (!is_processing() && scan_changes_pending) { + if (done_importing && scan_changes_pending) { scan_changes_pending = false; scan_changes(); } + + prevent_recursive_process_hack = false; } } break; } @@ -2167,6 +2184,11 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, HashMap void EditorFileSystem::reimport_file_with_custom_parameters(const String &p_file, const String &p_importer, const HashMap<StringName, Variant> &p_custom_params) { _reimport_file(p_file, p_custom_params, p_importer); + + // Emit the resource_reimported signal for the single file we just reimported. + Vector<String> reloads; + reloads.append(p_file); + emit_signal(SNAME("resources_reimported"), reloads); } void EditorFileSystem::_reimport_thread(uint32_t p_index, ImportThreadData *p_import_data) { @@ -2175,6 +2197,7 @@ void EditorFileSystem::_reimport_thread(uint32_t p_index, ImportThreadData *p_im } void EditorFileSystem::reimport_files(const Vector<String> &p_files) { + ERR_FAIL_COND_MSG(importing, "Attempted to call reimport_files() recursively, this is not allowed."); importing = true; Vector<String> reloads; |