diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-05-02 08:43:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-02 08:43:26 +0200 |
commit | d05f9efc9d5ee5af52eaf57722f1a2ff463d1b5f (patch) | |
tree | bc056f6cd057056ca0edf3516919cdae8d264616 /editor/editor_file_system.cpp | |
parent | 419d7976ca47c711efed957feab29b660eefdb3f (diff) | |
parent | dc7693867994620c390e619b91d23bdd1f8cba4e (diff) |
Merge pull request #46488 from kuruk-mm/fix_filesystem_bug
FileSystem: Force update when we delete a folder from the editor and …
Diffstat (limited to 'editor/editor_file_system.cpp')
-rw-r--r-- | editor/editor_file_system.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 59d3b09678..495bdd42f7 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -68,6 +68,11 @@ int EditorFileSystemDirectory::find_dir_index(const String &p_dir) const { return -1; } +void EditorFileSystemDirectory::force_update() { + // We set modified_time to 0 to force `EditorFileSystem::_scan_fs_changes` to search changes in the directory + modified_time = 0; +} + int EditorFileSystemDirectory::get_subdir_count() const { return subdirs.size(); } @@ -854,9 +859,11 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const //then scan files and directories and check what's different - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + + Error ret = da->change_dir(cd); + ERR_FAIL_COND_MSG(ret != OK, "Cannot change to '" + cd + "' folder."); - da->change_dir(cd); da->list_dir_begin(); while (true) { String f = da->get_next(); @@ -944,7 +951,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } da->list_dir_end(); - memdelete(da); } for (int i = 0; i < p_dir->files.size(); i++) { |