Fix the issue of no scan after dir creation and/or deletion

When `EditorFileDialog` creates/deletes a directory during interactive
operation, it needs to notify `EditorFileSystem` to scan and detect
the filesystem change.
This commit is contained in:
风青山 2025-12-04 10:36:39 +08:00
parent fbc9539764
commit 5ff8f21ff3
No known key found for this signature in database
GPG key ID: 8DFDAA198ED5EDF5
4 changed files with 29 additions and 2 deletions

View file

@ -30,6 +30,7 @@
#include "editor_file_dialog.h"
#include "core/config/project_settings.h"
#include "editor/docks/filesystem_dock.h"
#include "editor/file_system/dependency_editor.h"
#include "editor/settings/editor_settings.h"
@ -92,6 +93,26 @@ void EditorFileDialog::_validate_property(PropertyInfo &p_property) const {
}
}
void EditorFileDialog::_dir_contents_changed() {
bool scan_required = false;
switch (get_access()) {
case FileDialog::ACCESS_RESOURCES: {
scan_required = true;
} break;
case FileDialog::ACCESS_USERDATA: {
// Directories within the project dir are unlikely to be accessed.
} break;
case FileDialog::ACCESS_FILESYSTEM: {
// Directories within the project dir may still be accessed.
const String localized_path = ProjectSettings::get_singleton()->localize_path(get_current_dir());
scan_required = localized_path.is_resource_file();
} break;
}
if (scan_required) {
EditorFileSystem::get_singleton()->scan_changes();
}
}
void EditorFileDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {