Skip to content

Commit b438d21

Browse files
committed
Merge pull request #109391 from mihe/headless-progress-percentage
Fix headless import/export reporting progress greater than 100%
2 parents bbafe86 + e9aa270 commit b438d21

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

editor/editor_node.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5354,15 +5354,14 @@ bool EditorNode::is_object_of_custom_type(const Object *p_object, const StringNa
53545354
}
53555355

53565356
// Used to track the progress of tasks in the CLI output (since we don't have any other frame of reference).
5357-
// All tasks run sequentially, so we can just keep a single counter.
5358-
static int progress_total_steps = 0;
5357+
static HashMap<String, int> progress_total_steps;
53595358

53605359
void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
53615360
if (!singleton) {
53625361
return;
53635362
} else if (singleton->cmdline_mode) {
53645363
print_line_rich(vformat("[ 0%% ] [color=gray][b]%s[/b] | Started %s (%d steps)[/color]", p_task, p_label, p_steps));
5365-
progress_total_steps = p_steps;
5364+
progress_total_steps[p_task] = p_steps;
53665365
} else if (singleton->progress_dialog) {
53675366
singleton->progress_dialog->add_task(p_task, p_label, p_steps, p_can_cancel);
53685367
}
@@ -5372,7 +5371,7 @@ bool EditorNode::progress_task_step(const String &p_task, const String &p_state,
53725371
if (!singleton) {
53735372
return false;
53745373
} else if (singleton->cmdline_mode) {
5375-
const int percent = (p_step / float(progress_total_steps + 1)) * 100;
5374+
const int percent = (p_step / float(progress_total_steps[p_task] + 1)) * 100;
53765375
print_line_rich(vformat("[%4d%% ] [color=gray][b]%s[/b] | %s[/color]", percent, p_task, p_state));
53775376
return false;
53785377
} else if (singleton->progress_dialog) {
@@ -5386,6 +5385,7 @@ void EditorNode::progress_end_task(const String &p_task) {
53865385
if (!singleton) {
53875386
return;
53885387
} else if (singleton->cmdline_mode) {
5388+
progress_total_steps.erase(p_task);
53895389
print_line_rich(vformat("[color=green][ DONE ][/color] [b]%s[/b]\n", p_task));
53905390
} else if (singleton->progress_dialog) {
53915391
singleton->progress_dialog->end_task(p_task);

0 commit comments

Comments
 (0)