Prechádzať zdrojové kódy

editor: warn on UID duplicates
This commonly occurs when files are copied outside of the editor and don't get new UIDs.

Restricting this warning to first_scan since it's we want to exclude the case of files being moved after initial load which is harder to handle.

Addresses https://github.com/godotengine/godot-proposals/discussions/8949

David Nikdel 1 rok pred
rodič
commit
5122a3e3b0
1 zmenil súbory, kde vykonal 8 pridanie a 0 odobranie
  1. 8 0
      editor/editor_file_system.cpp

+ 8 - 0
editor/editor_file_system.cpp

@@ -961,6 +961,14 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc
 
 		if (fi->uid != ResourceUID::INVALID_ID) {
 			if (ResourceUID::get_singleton()->has_id(fi->uid)) {
+				// Restrict UID dupe warning to first-scan since we know there are no file moves going on yet.
+				if (first_scan) {
+					// Warn if we detect files with duplicate UIDs.
+					const String other_path = ResourceUID::get_singleton()->get_id_path(fi->uid);
+					if (other_path != path) {
+						WARN_PRINT(vformat("UID duplicate detected between %s and %s.", path, other_path));
+					}
+				}
 				ResourceUID::get_singleton()->set_id(fi->uid, path);
 			} else {
 				ResourceUID::get_singleton()->add_id(fi->uid, path);