summaryrefslogtreecommitdiffstats
path: root/editor/editor_resource_preview.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-03-01 16:32:49 -0300
committerJuan Linietsky <juan@godotengine.org>2019-03-01 16:34:03 -0300
commitabbca3b3ccebb367c326acb025757966a6f87486 (patch)
tree740d42158f6468e13b5ca04b6e25c5711e79e184 /editor/editor_resource_preview.cpp
parent856c36cb8964619716e7e1e6ec6d4c7498b5754b (diff)
downloadredot-engine-abbca3b3ccebb367c326acb025757966a6f87486.tar.gz
Flush stuff pending on visual server thread when exiting, fixes #24669
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r--editor/editor_resource_preview.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index e0c292dc87..9345ea6b6f 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -313,6 +313,8 @@ void EditorResourcePreview::_thread() {
preview_mutex->unlock();
}
}
+
+ exited = true;
}
void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
@@ -420,11 +422,16 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) {
void EditorResourcePreview::start() {
ERR_FAIL_COND(thread);
thread = Thread::create(_thread_func, this);
+ exited = false;
}
void EditorResourcePreview::stop() {
if (thread) {
exit = true;
preview_sem->post();
+ while (!exited) {
+ OS::get_singleton()->delay_usec(10000);
+ VisualServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server
+ }
Thread::wait_to_finish(thread);
memdelete(thread);
thread = NULL;
@@ -438,6 +445,7 @@ EditorResourcePreview::EditorResourcePreview() {
preview_sem = Semaphore::create();
order = 0;
exit = false;
+ exited = false;
}
EditorResourcePreview::~EditorResourcePreview() {