Skip to content

Commit d328c00

Browse files
committed
Merge pull request godotengine#99667 from RandomShaper/res_load_verb
ResourceLoader: Print load message only when actually loading
2 parents 7d30972 + 6740823 commit d328c00

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

core/io/resource_loader.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
294294
}
295295
load_paths_stack.push_back(original_path);
296296

297+
print_verbose(vformat("Loading resource: %s", p_path));
298+
297299
// Try all loaders and pick the first match for the type hint
298300
bool found = false;
299301
Ref<Resource> res;
@@ -303,7 +305,7 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
303305
}
304306
found = true;
305307
res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode);
306-
if (!res.is_null()) {
308+
if (res.is_valid()) {
307309
break;
308310
}
309311
}
@@ -312,8 +314,10 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
312314
res_ref_overrides.erase(load_nesting);
313315
load_nesting--;
314316

315-
if (!res.is_null()) {
317+
if (res.is_valid()) {
316318
return res;
319+
} else {
320+
print_verbose(vformat("Failed loading resource: %s", p_path));
317321
}
318322

319323
ERR_FAIL_COND_V_MSG(found, Ref<Resource>(),
@@ -361,18 +365,12 @@ void ResourceLoader::_run_load_task(void *p_userdata) {
361365
bool xl_remapped = false;
362366
const String &remapped_path = _path_remap(load_task.local_path, &xl_remapped);
363367

364-
print_verbose("Loading resource: " + remapped_path);
365-
366368
Error load_err = OK;
367369
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);
368370
if (MessageQueue::get_singleton() != MessageQueue::get_main_singleton()) {
369371
MessageQueue::get_singleton()->flush();
370372
}
371373

372-
if (res.is_null()) {
373-
print_verbose("Failed loading resource: " + remapped_path);
374-
}
375-
376374
thread_load_mutex.lock();
377375

378376
load_task.resource = res;

0 commit comments

Comments
 (0)