Perform a cleaner exit for resource preview, fixes #24206
This commit is contained in:
parent
3b46e99a39
commit
e8d31cc765
4 changed files with 26 additions and 10 deletions
|
@ -494,7 +494,7 @@ void EditorNode::_fs_changed() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get_tree()->quit();
|
_exit_editor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,7 +1120,7 @@ void EditorNode::save_all_scenes_and_restart() {
|
||||||
to_reopen = get_tree()->get_edited_scene_root()->get_filename();
|
to_reopen = get_tree()->get_edited_scene_root()->get_filename();
|
||||||
}
|
}
|
||||||
|
|
||||||
get_tree()->quit();
|
_exit_editor();
|
||||||
String exec = OS::get_singleton()->get_executable_path();
|
String exec = OS::get_singleton()->get_executable_path();
|
||||||
|
|
||||||
List<String> args;
|
List<String> args;
|
||||||
|
@ -2356,6 +2356,12 @@ int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorNode::_exit_editor() {
|
||||||
|
exiting = true;
|
||||||
|
resource_preview->stop(); //stop early to avoid crashes
|
||||||
|
get_tree()->quit();
|
||||||
|
}
|
||||||
|
|
||||||
void EditorNode::_discard_changes(const String &p_str) {
|
void EditorNode::_discard_changes(const String &p_str) {
|
||||||
|
|
||||||
switch (current_option) {
|
switch (current_option) {
|
||||||
|
@ -2383,14 +2389,13 @@ void EditorNode::_discard_changes(const String &p_str) {
|
||||||
case FILE_QUIT: {
|
case FILE_QUIT: {
|
||||||
|
|
||||||
_menu_option_confirm(RUN_STOP, true);
|
_menu_option_confirm(RUN_STOP, true);
|
||||||
exiting = true;
|
_exit_editor();
|
||||||
get_tree()->quit();
|
|
||||||
} break;
|
} break;
|
||||||
case RUN_PROJECT_MANAGER: {
|
case RUN_PROJECT_MANAGER: {
|
||||||
|
|
||||||
_menu_option_confirm(RUN_STOP, true);
|
_menu_option_confirm(RUN_STOP, true);
|
||||||
exiting = true;
|
_exit_editor();
|
||||||
get_tree()->quit();
|
|
||||||
String exec = OS::get_singleton()->get_executable_path();
|
String exec = OS::get_singleton()->get_executable_path();
|
||||||
|
|
||||||
List<String> args;
|
List<String> args;
|
||||||
|
|
|
@ -470,6 +470,8 @@ private:
|
||||||
void _dropped_files(const Vector<String> &p_files, int p_screen);
|
void _dropped_files(const Vector<String> &p_files, int p_screen);
|
||||||
String _recent_scene;
|
String _recent_scene;
|
||||||
|
|
||||||
|
void _exit_editor();
|
||||||
|
|
||||||
bool convert_old;
|
bool convert_old;
|
||||||
|
|
||||||
void _unhandled_input(const Ref<InputEvent> &p_event);
|
void _unhandled_input(const Ref<InputEvent> &p_event);
|
||||||
|
|
|
@ -416,6 +416,16 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorResourcePreview::stop() {
|
||||||
|
if (thread) {
|
||||||
|
exit = true;
|
||||||
|
preview_sem->post();
|
||||||
|
Thread::wait_to_finish(thread);
|
||||||
|
memdelete(thread);
|
||||||
|
thread = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EditorResourcePreview::EditorResourcePreview() {
|
EditorResourcePreview::EditorResourcePreview() {
|
||||||
singleton = this;
|
singleton = this;
|
||||||
preview_mutex = Mutex::create();
|
preview_mutex = Mutex::create();
|
||||||
|
@ -428,10 +438,7 @@ EditorResourcePreview::EditorResourcePreview() {
|
||||||
|
|
||||||
EditorResourcePreview::~EditorResourcePreview() {
|
EditorResourcePreview::~EditorResourcePreview() {
|
||||||
|
|
||||||
exit = true;
|
stop();
|
||||||
preview_sem->post();
|
|
||||||
Thread::wait_to_finish(thread);
|
|
||||||
memdelete(thread);
|
|
||||||
memdelete(preview_mutex);
|
memdelete(preview_mutex);
|
||||||
memdelete(preview_sem);
|
memdelete(preview_sem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,8 @@ public:
|
||||||
void remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator);
|
void remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator);
|
||||||
void check_for_invalidation(const String &p_path);
|
void check_for_invalidation(const String &p_path);
|
||||||
|
|
||||||
|
void stop();
|
||||||
|
|
||||||
EditorResourcePreview();
|
EditorResourcePreview();
|
||||||
~EditorResourcePreview();
|
~EditorResourcePreview();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue