Skip to content

Commit 46dcc5e

Browse files
committed
ResourceLoader: Fix potential infinite recursion in progress reporting
1 parent 235a32a commit 46dcc5e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/io/resource_loader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,11 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
666666
float ResourceLoader::_dependency_get_progress(const String &p_path) {
667667
if (thread_load_tasks.has(p_path)) {
668668
ThreadLoadTask &load_task = thread_load_tasks[p_path];
669+
if (load_task.in_progress_check) {
670+
// Avoid cycles.
671+
return load_task.max_reported_progress;
672+
}
673+
load_task.in_progress_check = true;
669674
float current_progress = 0.0;
670675
int dep_count = load_task.sub_tasks.size();
671676
if (dep_count > 0) {
@@ -679,6 +684,7 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) {
679684
current_progress = load_task.progress;
680685
}
681686
load_task.max_reported_progress = MAX(load_task.max_reported_progress, current_progress);
687+
load_task.in_progress_check = false;
682688
return load_task.max_reported_progress;
683689
} else {
684690
return 1.0; //assume finished loading it so it no longer exists

core/io/resource_loader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class ResourceLoader {
185185
String type_hint;
186186
float progress = 0.0f;
187187
float max_reported_progress = 0.0f;
188+
bool in_progress_check = false;
188189
uint64_t last_progress_check_main_thread_frame = UINT64_MAX;
189190
ThreadLoadStatus status = THREAD_LOAD_IN_PROGRESS;
190191
ResourceFormatLoader::CacheMode cache_mode = ResourceFormatLoader::CACHE_MODE_REUSE;

0 commit comments

Comments
 (0)