summaryrefslogtreecommitdiff
path: root/editor/editor_resource_preview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r--editor/editor_resource_preview.cpp15
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);
}