From e0e5a8cc91432142996dfe5de22a685c31be48e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Thu, 12 Sep 2024 11:46:31 +0200 Subject: [PATCH] EditorResourcePreview: Let loads complete after exit requested (cherry picked from commit 213fda4ebfc0568d81e38a7fe635c41985fbbf4b) --- editor/editor_node.cpp | 3 ++- editor/editor_resource_preview.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f24fa344ae55..26bb3053215d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3353,12 +3353,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 71865f7e8cc0..b4097c7890f5 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" @@ -531,8 +532,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();