Skip to content

Commit

Permalink
EditorResourcePreview: Let loads complete after exit requested
Browse files Browse the repository at this point in the history
(cherry picked from commit 213fda4)
  • Loading branch information
RandomShaper committed Sep 12, 2024
1 parent e046ce9 commit e0e5a8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions editor/editor_resource_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit e0e5a8c

Please sign in to comment.