diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 39291138a677..f1f3013cc4a0 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3423,12 +3423,13 @@ int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) { void EditorNode::_exit_editor(int p_exit_code) { exiting = true; - resource_preview->stop(); // Stop early to avoid crashes. _save_editor_layout(); // Dim the editor window while it's quitting to make it clearer that it's busy. dim_editor(true); + resource_preview->stop(); + // Unload addons before quitting to allow cleanup. unload_editor_addons(); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 956fdc5cfa70..89058bd6c18f 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -40,6 +40,7 @@ #include "editor/editor_settings.h" #include "editor/editor_string_names.h" #include "editor/themes/editor_scale.h" +#include "main/main.h" #include "scene/main/window.h" #include "scene/resources/image_texture.h" #include "servers/rendering/rendering_server_default.h" @@ -533,8 +534,8 @@ void EditorResourcePreview::stop() { } while (!exited.is_set()) { - OS::get_singleton()->delay_usec(10000); - RenderingServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on rendering server + // Sync pending work (message queue, render). + Main::iteration(); } thread.wait_to_finish();