diff options
Diffstat (limited to 'editor/editor_file_system.cpp')
-rw-r--r-- | editor/editor_file_system.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 76814ea378..4b68de26e7 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -595,7 +595,7 @@ void EditorFileSystem::scan() { return; } - if (scanning || scanning_changes || thread) { + if (scanning || scanning_changes || thread.is_started()) { return; } @@ -619,13 +619,13 @@ void EditorFileSystem::scan() { _queue_update_script_classes(); first_scan = false; } else { - ERR_FAIL_COND(thread); + ERR_FAIL_COND(thread.is_started()); set_process(true); Thread::Settings s; scanning = true; scan_total = 0; s.priority = Thread::PRIORITY_LOW; - thread = Thread::create(_thread_func, this, s); + thread.start(_thread_func, this, s); //tree->hide(); //progress->show(); } @@ -1046,7 +1046,7 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) { void EditorFileSystem::scan_changes() { if (first_scan || // Prevent a premature changes scan from inhibiting the first full scan - scanning || scanning_changes || thread) { + scanning || scanning_changes || thread.is_started()) { scan_changes_pending = true; set_process(true); return; @@ -1076,12 +1076,12 @@ void EditorFileSystem::scan_changes() { scanning_changes_done = true; emit_signal("sources_changed", sources_changed.size() > 0); } else { - ERR_FAIL_COND(thread_sources); + ERR_FAIL_COND(thread_sources.is_started()); set_process(true); scan_total = 0; Thread::Settings s; s.priority = Thread::PRIORITY_LOW; - thread_sources = Thread::create(_thread_func_sources, this, s); + thread_sources.start(_thread_func_sources, this, s); } } @@ -1092,17 +1092,14 @@ void EditorFileSystem::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - Thread *active_thread = thread ? thread : thread_sources; - if (use_threads && active_thread) { + Thread &active_thread = thread.is_started() ? thread : thread_sources; + if (use_threads && active_thread.is_started()) { //abort thread if in progress abort_scan = true; while (scanning) { OS::get_singleton()->delay_usec(1000); } - Thread::wait_to_finish(active_thread); - memdelete(active_thread); - thread = nullptr; - thread_sources = nullptr; + active_thread.wait_to_finish(); WARN_PRINT("Scan thread aborted..."); set_process(false); } @@ -1125,9 +1122,7 @@ void EditorFileSystem::_notification(int p_what) { set_process(false); - Thread::wait_to_finish(thread_sources); - memdelete(thread_sources); - thread_sources = nullptr; + thread_sources.wait_to_finish(); if (_update_scan_actions()) { emit_signal("filesystem_changed"); } @@ -1135,7 +1130,7 @@ void EditorFileSystem::_notification(int p_what) { _queue_update_script_classes(); first_scan = false; } - } else if (!scanning && thread) { + } else if (!scanning && thread.is_started()) { set_process(false); if (filesystem) { @@ -1143,9 +1138,7 @@ void EditorFileSystem::_notification(int p_what) { } filesystem = new_filesystem; new_filesystem = nullptr; - Thread::wait_to_finish(thread); - memdelete(thread); - thread = nullptr; + thread.wait_to_finish(); _update_scan_actions(); emit_signal("filesystem_changed"); emit_signal("sources_changed", sources_changed.size() > 0); @@ -2080,11 +2073,9 @@ EditorFileSystem::EditorFileSystem() { filesystem = memnew(EditorFileSystemDirectory); //like, empty filesystem->parent = nullptr; - thread = nullptr; scanning = false; importing = false; use_threads = true; - thread_sources = nullptr; new_filesystem = nullptr; abort_scan = false; |