summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-10 17:42:24 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-10-10 17:42:24 +0200
commitdb7047705b4f7896f89cd7652a7868a7668c18a4 (patch)
treeae6722162c5c83f125dcfee71ac77e30b8a045dc /editor
parent3c413cf00850c279f55b30075960f25de53e38f2 (diff)
parenta38891dfb3851d0e119bc418994f9bbf1436be86 (diff)
Merge pull request #67124 from KoBeWi/load_before_save
Fallback to ResourceLoader if can't find UID
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_file_system.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 651501f75e..c28bb18891 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -2259,7 +2259,7 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new
ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) {
if (!p_path.is_resource_file() || p_path.begins_with(ProjectSettings::get_singleton()->get_project_data_path())) {
- //saved externally (configuration file) or internal file, do not assign an ID.
+ // Saved externally (configuration file) or internal file, do not assign an ID.
return ResourceUID::INVALID_ID;
}
@@ -2267,15 +2267,21 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const
int cpos = -1;
if (!singleton->_find_file(p_path, &fs, cpos)) {
+ // Fallback to ResourceLoader if filesystem cache fails (can happen during scanning etc.).
+ ResourceUID::ID fallback = ResourceLoader::get_resource_uid(p_path);
+ if (fallback != ResourceUID::INVALID_ID) {
+ return fallback;
+ }
+
if (p_generate) {
- return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
+ return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
} else {
return ResourceUID::INVALID_ID;
}
} else if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) {
return fs->files[cpos]->uid;
} else if (p_generate) {
- return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
+ return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple.
} else {
return ResourceUID::INVALID_ID;
}