ResourceLoader: Fix potential infinite recursion in progress reporting
This commit is contained in:
parent
235a32ad11
commit
5806e3c761
2 changed files with 20 additions and 4 deletions
|
|
@ -666,6 +666,14 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
|
|||
float ResourceLoader::_dependency_get_progress(const String &p_path) {
|
||||
if (thread_load_tasks.has(p_path)) {
|
||||
ThreadLoadTask &load_task = thread_load_tasks[p_path];
|
||||
if (load_task.in_progress_check) {
|
||||
// Given the fact that any resource loaded when an outer stack frame is
|
||||
// loading another one is considered a dependency of it, for progress
|
||||
// tracking purposes, a cycle can happen if even if the original resource
|
||||
// graphs involved have none. For instance, preload() can cause this.
|
||||
return load_task.max_reported_progress;
|
||||
}
|
||||
load_task.in_progress_check = true;
|
||||
float current_progress = 0.0;
|
||||
int dep_count = load_task.sub_tasks.size();
|
||||
if (dep_count > 0) {
|
||||
|
|
@ -679,6 +687,7 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) {
|
|||
current_progress = load_task.progress;
|
||||
}
|
||||
load_task.max_reported_progress = MAX(load_task.max_reported_progress, current_progress);
|
||||
load_task.in_progress_check = false;
|
||||
return load_task.max_reported_progress;
|
||||
} else {
|
||||
return 1.0; //assume finished loading it so it no longer exists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue