diff --git a/editor/docks/filesystem_dock.cpp b/editor/docks/filesystem_dock.cpp index 35b8f11b7c..cc19ffa116 100644 --- a/editor/docks/filesystem_dock.cpp +++ b/editor/docks/filesystem_dock.cpp @@ -1619,19 +1619,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin } } -void FileSystemDock::_update_resource_paths_after_move(const HashMap &p_renames, const HashMap &p_uids) const { - for (const KeyValue &pair : p_renames) { - // Update UID path. - const String &old_path = pair.key; - const String &new_path = pair.value; - - const HashMap::ConstIterator I = p_uids.find(old_path); - if (I) { - ResourceUID::get_singleton()->set_id(I->value, new_path); - } - EditorFileSystem::get_singleton()->register_global_class_script(old_path, new_path); - } - +void FileSystemDock::_update_resource_paths_after_move(const HashMap &p_renames) const { // Rename all resources loaded, be it subresources or actual resources. List> cached; ResourceCache::get_cached_resources(&cached); @@ -1651,8 +1639,17 @@ void FileSystemDock::_update_resource_paths_after_move(const HashMapemit_signal(SNAME("script_classes_updated")); + Vector files_to_update; + for (const KeyValue &E : p_renames) { + if (!files_to_update.has(E.key)) { + files_to_update.push_back(E.key); + } + if (!files_to_update.has(E.value)) { + files_to_update.push_back(E.value); + } + } + print_verbose("FileSystem: updating file infos."); + EditorFileSystem::get_singleton()->update_files(files_to_update); } void FileSystemDock::_update_dependencies_after_move(const HashMap &p_renames, const HashSet &p_file_owners) const { @@ -1897,16 +1894,15 @@ void FileSystemDock::_rename_operation_confirm() { return; } - HashMap uids; HashSet file_owners; // The files that use these moved/renamed resource files. - _before_move(uids, file_owners); + _before_move(file_owners); HashMap file_renames; HashMap folder_renames; _try_move_item(to_rename, new_path, file_renames, folder_renames); int current_tab = EditorSceneTabs::get_singleton()->get_current_tab(); - _update_resource_paths_after_move(file_renames, uids); + _update_resource_paths_after_move(file_renames); _update_dependencies_after_move(file_renames, file_owners); _update_project_settings_after_move(file_renames, folder_renames); _update_favorites_after_move(file_renames, folder_renames); @@ -2051,9 +2047,8 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_cop } } - HashMap uids; HashSet file_owners; // The files that use these moved/renamed resource files. - _before_move(uids, file_owners); + _before_move(file_owners); bool is_moved = false; HashMap file_renames; @@ -2067,20 +2062,8 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_cop } if (is_moved) { - Vector files_to_update; - for (KeyValue &E : file_renames) { - if (!files_to_update.has(E.key)) { - files_to_update.push_back(E.key); - } - if (!files_to_update.has(E.value)) { - files_to_update.push_back(E.value); - } - } - print_verbose("FileSystem: updating file infos."); - EditorFileSystem::get_singleton()->update_files(files_to_update); - int current_tab = EditorSceneTabs::get_singleton()->get_current_tab(); - _update_resource_paths_after_move(file_renames, uids); + _update_resource_paths_after_move(file_renames); _update_dependencies_after_move(file_renames, file_owners); _update_project_settings_after_move(file_renames, folder_renames); _update_favorites_after_move(file_renames, folder_renames); @@ -2096,15 +2079,11 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_cop } } -void FileSystemDock::_before_move(HashMap &r_uids, HashSet &r_file_owners) const { +void FileSystemDock::_before_move(HashSet &r_file_owners) const { HashSet renamed_files; for (int i = 0; i < to_move.size(); i++) { if (to_move[i].is_file) { renamed_files.insert(to_move[i].path); - ResourceUID::ID uid = ResourceLoader::get_resource_uid(to_move[i].path); - if (uid != ResourceUID::INVALID_ID) { - r_uids[to_move[i].path] = uid; - } } else { EditorFileSystemDirectory *current_folder = EditorFileSystem::get_singleton()->get_filesystem_path(to_move[i].path); ERR_CONTINUE(current_folder == nullptr); @@ -2115,10 +2094,6 @@ void FileSystemDock::_before_move(HashMap &r_uids, Hash for (int j = 0; j < current_folder->get_file_count(); j++) { const String file_path = current_folder->get_file_path(j); renamed_files.insert(file_path); - ResourceUID::ID uid = ResourceLoader::get_resource_uid(file_path); - if (uid != ResourceUID::INVALID_ID) { - r_uids[file_path] = uid; - } } for (int j = 0; j < current_folder->get_subdir_count(); j++) { folders.push_back(current_folder->get_subdir(j)); diff --git a/editor/docks/filesystem_dock.h b/editor/docks/filesystem_dock.h index a56c23be94..18f26d8f7d 100644 --- a/editor/docks/filesystem_dock.h +++ b/editor/docks/filesystem_dock.h @@ -303,9 +303,9 @@ private: void _find_file_owners(EditorFileSystemDirectory *p_efsd, const HashSet &p_renames, HashSet &r_file_owners) const; void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, HashMap &p_file_renames, HashMap &p_folder_renames); void _try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const; - void _before_move(HashMap &r_uids, HashSet &r_file_owners) const; + void _before_move(HashSet &r_file_owners) const; void _update_dependencies_after_move(const HashMap &p_renames, const HashSet &p_file_owners) const; - void _update_resource_paths_after_move(const HashMap &p_renames, const HashMap &p_uids) const; + void _update_resource_paths_after_move(const HashMap &p_renames) const; void _update_favorites_after_move(const HashMap &p_files_renames, const HashMap &p_folders_renames) const; void _update_project_settings_after_move(const HashMap &p_renames, const HashMap &p_folders_renames); String _get_unique_name(const FileOrFolder &p_entry, const String &p_at_path);