Browse Source

ResourceLoader: Print load message only when actually loading

Pedro J. Estébanez 9 months ago
parent
commit
6740823e40
1 changed files with 6 additions and 8 deletions
  1. 6 8
      core/io/resource_loader.cpp

+ 6 - 8
core/io/resource_loader.cpp

@@ -294,6 +294,8 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
 	}
 	}
 	load_paths_stack.push_back(original_path);
 	load_paths_stack.push_back(original_path);
 
 
+	print_verbose(vformat("Loading resource: %s", p_path));
+
 	// Try all loaders and pick the first match for the type hint
 	// Try all loaders and pick the first match for the type hint
 	bool found = false;
 	bool found = false;
 	Ref<Resource> res;
 	Ref<Resource> res;
@@ -303,7 +305,7 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
 		}
 		}
 		found = true;
 		found = true;
 		res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode);
 		res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode);
-		if (!res.is_null()) {
+		if (res.is_valid()) {
 			break;
 			break;
 		}
 		}
 	}
 	}
@@ -312,8 +314,10 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
 	res_ref_overrides.erase(load_nesting);
 	res_ref_overrides.erase(load_nesting);
 	load_nesting--;
 	load_nesting--;
 
 
-	if (!res.is_null()) {
+	if (res.is_valid()) {
 		return res;
 		return res;
+	} else {
+		print_verbose(vformat("Failed loading resource: %s", p_path));
 	}
 	}
 
 
 	ERR_FAIL_COND_V_MSG(found, Ref<Resource>(),
 	ERR_FAIL_COND_V_MSG(found, Ref<Resource>(),
@@ -361,18 +365,12 @@ void ResourceLoader::_run_load_task(void *p_userdata) {
 	bool xl_remapped = false;
 	bool xl_remapped = false;
 	const String &remapped_path = _path_remap(load_task.local_path, &xl_remapped);
 	const String &remapped_path = _path_remap(load_task.local_path, &xl_remapped);
 
 
-	print_verbose("Loading resource: " + remapped_path);
-
 	Error load_err = OK;
 	Error load_err = OK;
 	Ref<Resource> res = _load(remapped_path, remapped_path != load_task.local_path ? load_task.local_path : String(), load_task.type_hint, load_task.cache_mode, &load_err, load_task.use_sub_threads, &load_task.progress);
 	Ref<Resource> res = _load(remapped_path, remapped_path != load_task.local_path ? load_task.local_path : String(), load_task.type_hint, load_task.cache_mode, &load_err, load_task.use_sub_threads, &load_task.progress);
 	if (MessageQueue::get_singleton() != MessageQueue::get_main_singleton()) {
 	if (MessageQueue::get_singleton() != MessageQueue::get_main_singleton()) {
 		MessageQueue::get_singleton()->flush();
 		MessageQueue::get_singleton()->flush();
 	}
 	}
 
 
-	if (res.is_null()) {
-		print_verbose("Failed loading resource: " + remapped_path);
-	}
-
 	thread_load_mutex.lock();
 	thread_load_mutex.lock();
 
 
 	load_task.resource = res;
 	load_task.resource = res;