mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 05:31:01 +00:00 
			
		
		
		
	Merge pull request #83039 from KoBeWi/it's_always_the_cache
Fix GDScript cache assigning UID as scene path
This commit is contained in:
		
						commit
						a9c864dc35
					
				
					 1 changed files with 15 additions and 10 deletions
				
			
		|  | @ -364,28 +364,33 @@ void GDScriptCache::remove_static_script(const String &p_fqcn) { | ||||||
| Ref<PackedScene> GDScriptCache::get_packed_scene(const String &p_path, Error &r_error, const String &p_owner) { | Ref<PackedScene> GDScriptCache::get_packed_scene(const String &p_path, Error &r_error, const String &p_owner) { | ||||||
| 	MutexLock lock(singleton->mutex); | 	MutexLock lock(singleton->mutex); | ||||||
| 
 | 
 | ||||||
| 	if (singleton->packed_scene_cache.has(p_path)) { | 	String path = p_path; | ||||||
| 		singleton->packed_scene_dependencies[p_path].insert(p_owner); | 	if (path.begins_with("uid://")) { | ||||||
| 		return singleton->packed_scene_cache[p_path]; | 		path = ResourceUID::get_singleton()->get_id_path(ResourceUID::get_singleton()->text_to_id(path)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	Ref<PackedScene> scene = ResourceCache::get_ref(p_path); | 	if (singleton->packed_scene_cache.has(path)) { | ||||||
|  | 		singleton->packed_scene_dependencies[path].insert(p_owner); | ||||||
|  | 		return singleton->packed_scene_cache[path]; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	Ref<PackedScene> scene = ResourceCache::get_ref(path); | ||||||
| 	if (scene.is_valid()) { | 	if (scene.is_valid()) { | ||||||
| 		singleton->packed_scene_cache[p_path] = scene; | 		singleton->packed_scene_cache[path] = scene; | ||||||
| 		singleton->packed_scene_dependencies[p_path].insert(p_owner); | 		singleton->packed_scene_dependencies[path].insert(p_owner); | ||||||
| 		return scene; | 		return scene; | ||||||
| 	} | 	} | ||||||
| 	scene.instantiate(); | 	scene.instantiate(); | ||||||
| 
 | 
 | ||||||
| 	r_error = OK; | 	r_error = OK; | ||||||
| 	if (p_path.is_empty()) { | 	if (path.is_empty()) { | ||||||
| 		r_error = ERR_FILE_BAD_PATH; | 		r_error = ERR_FILE_BAD_PATH; | ||||||
| 		return scene; | 		return scene; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	scene->set_path(p_path); | 	scene->set_path(path); | ||||||
| 	singleton->packed_scene_cache[p_path] = scene; | 	singleton->packed_scene_cache[path] = scene; | ||||||
| 	singleton->packed_scene_dependencies[p_path].insert(p_owner); | 	singleton->packed_scene_dependencies[path].insert(p_owner); | ||||||
| 
 | 
 | ||||||
| 	scene->reload_from_file(); | 	scene->reload_from_file(); | ||||||
| 	return scene; | 	return scene; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rémi Verschelde
						Rémi Verschelde