diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-01-17 09:09:01 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-01-17 09:09:39 -0300 |
commit | e8d31cc765d520802c425965ebb4f2eeb220dce7 (patch) | |
tree | dc8aaaa51c1d2e2a553b45c0322c7449d630db9e /editor/editor_resource_preview.cpp | |
parent | 3b46e99a394d03295869f3b70cfa96fb9c998901 (diff) | |
download | redot-engine-e8d31cc765d520802c425965ebb4f2eeb220dce7.tar.gz |
Perform a cleaner exit for resource preview, fixes #24206
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r-- | editor/editor_resource_preview.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 25139b0163..368efbc48f 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -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() { singleton = this; preview_mutex = Mutex::create(); @@ -428,10 +438,7 @@ EditorResourcePreview::EditorResourcePreview() { EditorResourcePreview::~EditorResourcePreview() { - exit = true; - preview_sem->post(); - Thread::wait_to_finish(thread); - memdelete(thread); + stop(); memdelete(preview_mutex); memdelete(preview_sem); } |