Skip to content

Commit 181f2a2

Browse files
committed
EditorFileSystem: Simplify resource loading logic on startup
1 parent 53be3b7 commit 181f2a2

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
@@ -3388,24 +3388,17 @@ Ref<Resource> EditorFileSystem::_load_resource_on_startup(ResourceFormatImporter
33883388
ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Failed loading resource: %s. The file doesn't seem to exist.", p_path));
33893389
}
33903390

3391-
Ref<Resource> res;
3392-
bool can_retry = true;
3393-
bool retry = true;
3394-
while (retry) {
3395-
retry = false;
3396-
3397-
res = p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, can_retry);
3398-
3399-
if (res.is_null() && can_retry) {
3400-
can_retry = false;
3401-
Error err = singleton->_reimport_file(p_path, HashMap<StringName, Variant>(), "", nullptr, false);
3402-
if (err == OK) {
3403-
retry = true;
3404-
}
3405-
}
3391+
// Fail silently. Hopefully the resource is not yet imported.
3392+
Ref<Resource> res = p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, true);
3393+
if (res.is_valid()) {
3394+
return res;
34063395
}
34073396

3408-
return res;
3397+
// Retry after importing the resource.
3398+
if (singleton->_reimport_file(p_path, HashMap<StringName, Variant>(), "", nullptr, false) != OK) {
3399+
return Ref<Resource>();
3400+
}
3401+
return p_importer->load_internal(p_path, r_error, p_use_sub_threads, r_progress, p_cache_mode, false);
34093402
}
34103403

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

0 commit comments

Comments
 (0)