Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data race against EditorFileSystem.scanning_changes_done #88124

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) {
sp.low = 0;
efs->_scan_fs_changes(efs->filesystem, sp);
}
efs->scanning_changes_done = true;
efs->scanning_changes_done.set();
}

void EditorFileSystem::scan_changes() {
Expand All @@ -1197,7 +1197,7 @@ void EditorFileSystem::scan_changes() {
_update_extensions();
sources_changed.clear();
scanning_changes = true;
scanning_changes_done = false;
scanning_changes_done.clear();

if (!use_threads) {
if (filesystem) {
Expand All @@ -1216,7 +1216,7 @@ void EditorFileSystem::scan_changes() {
}
}
scanning_changes = false;
scanning_changes_done = true;
scanning_changes_done.set();
emit_signal(SNAME("sources_changed"), sources_changed.size() > 0);
} else {
ERR_FAIL_COND(thread_sources.is_started());
Expand Down Expand Up @@ -1269,7 +1269,7 @@ void EditorFileSystem::_notification(int p_what) {
bool done_importing = false;

if (scanning_changes) {
if (scanning_changes_done) {
if (scanning_changes_done.is_set()) {
set_process(false);

if (thread_sources.is_started()) {
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class EditorFileSystem : public Node {

Thread thread_sources;
bool scanning_changes = false;
bool scanning_changes_done = false;
SafeFlag scanning_changes_done;

static void _thread_func_sources(void *_userdata);

Expand Down
Loading