Skip to content

Commit e172334

Browse files
committed
Merge pull request #108236 from timothyqiu/simplify-while
EditorFileSystem: Simplify resource loading logic on startup
2 parents 809e0c7 + 181f2a2 commit e172334

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

editor/file_system/editor_file_system.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,24 +3420,17 @@ Ref<Resource> EditorFileSystem::_load_resource_on_startup(ResourceFormatImporter
34203420
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Failed loading resource: %s. The file doesn't seem to exist.", p_path));
34213421
}
34223422

3423-
Ref<Resource> res;
3424-
bool can_retry = true;
3425-
bool retry = true;
3426-
while (retry) {
3427-
retry = false;
3428-
3429-
res = p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, can_retry);
3430-
3431-
if (res.is_null() && can_retry) {
3432-
can_retry = false;
3433-
Error err = singleton->_reimport_file(p_path, HashMap<StringName, Variant>(), "", nullptr, false);
3434-
if (err == OK) {
3435-
retry = true;
3436-
}
3437-
}
3423+
// Fail silently. Hopefully the resource is not yet imported.
3424+
Ref<Resource> res = p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, true);
3425+
if (res.is_valid()) {
3426+
return res;
34383427
}
34393428

3440-
return res;
3429+
// Retry after importing the resource.
3430+
if (singleton->_reimport_file(p_path, HashMap<StringName, Variant>(), "", nullptr, false) != OK) {
3431+
return Ref<Resource>();
3432+
}
3433+
return p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, false);
34413434
}
34423435

34433436
bool EditorFileSystem::_should_skip_directory(const String &p_path) {

0 commit comments

Comments
 (0)