Skip to content

Commit

Permalink
Merge pull request godotengine#98584 from Nazarwadim/emit_only_one_si…
Browse files Browse the repository at this point in the history
…gnal

Emit `filesystem_changed` only once per frame
  • Loading branch information
clayjohn authored Oct 30, 2024
2 parents 8004c75 + 01d1f10 commit a997001
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2376,10 +2376,18 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
if (!is_scanning()) {
_process_update_pending();
}
call_deferred(SNAME("emit_signal"), "filesystem_changed"); // Update later
if (!filesystem_changed_queued) {
filesystem_changed_queued = true;
callable_mp(this, &EditorFileSystem::_notify_filesystem_changed).call_deferred();
}
}
}

void EditorFileSystem::_notify_filesystem_changed() {
emit_signal("filesystem_changed");
filesystem_changed_queued = false;
}

HashSet<String> EditorFileSystem::get_valid_extensions() const {
return valid_extensions;
}
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class EditorFileSystem : public Node {
EditorFileSystemDirectory *new_filesystem = nullptr;
ScannedDirectory *first_scan_root_dir = nullptr;

bool filesystem_changed_queued = false;
bool scanning = false;
bool importing = false;
bool first_scan = true;
Expand All @@ -189,6 +190,7 @@ class EditorFileSystem : public Node {
bool revalidate_import_files = false;
int nb_files_total = 0;

void _notify_filesystem_changed();
void _scan_filesystem();
void _first_scan_filesystem();
void _first_scan_process_scripts(const ScannedDirectory *p_scan_dir, List<String> &p_gdextension_extensions, HashSet<String> &p_existing_class_names, HashSet<String> &p_extensions);
Expand Down

0 comments on commit a997001

Please sign in to comment.