Merge pull request #96551 from DCTewi/fix-editor-progress-error

Fix ProcessDialog errors appeared after rebuilding .NET project
This commit is contained in:
Rémi Verschelde 2024-09-04 17:12:13 +02:00
commit df44d6a2e7
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 19 additions and 7 deletions

View File

@ -1896,7 +1896,12 @@ void EditorFileSystem::_update_script_classes() {
EditorProgress *ep = nullptr; EditorProgress *ep = nullptr;
if (update_script_paths.size() > 1) { if (update_script_paths.size() > 1) {
ep = memnew(EditorProgress("update_scripts_classes", TTR("Registering global classes..."), update_script_paths.size())); if (MessageQueue::get_singleton()->is_flushing()) {
// Use background progress when message queue is flushing.
ep = memnew(EditorProgress("update_scripts_classes", TTR("Registering global classes..."), update_script_paths.size(), false, true));
} else {
ep = memnew(EditorProgress("update_scripts_classes", TTR("Registering global classes..."), update_script_paths.size()));
}
} }
int step_count = 0; int step_count = 0;
@ -1935,7 +1940,12 @@ void EditorFileSystem::_update_script_documentation() {
EditorProgress *ep = nullptr; EditorProgress *ep = nullptr;
if (update_script_paths_documentation.size() > 1) { if (update_script_paths_documentation.size() > 1) {
ep = memnew(EditorProgress("update_script_paths_documentation", TTR("Updating scripts documentation"), update_script_paths_documentation.size())); if (MessageQueue::get_singleton()->is_flushing()) {
// Use background progress when message queue is flushing.
ep = memnew(EditorProgress("update_script_paths_documentation", TTR("Updating scripts documentation"), update_script_paths_documentation.size(), false, true));
} else {
ep = memnew(EditorProgress("update_script_paths_documentation", TTR("Updating scripts documentation"), update_script_paths_documentation.size()));
}
} }
int step_count = 0; int step_count = 0;

View File

@ -175,7 +175,7 @@ static const String REMOVE_ANDROID_BUILD_TEMPLATE_MESSAGE = "The Android build t
static const String INSTALL_ANDROID_BUILD_TEMPLATE_MESSAGE = "This will set up your project for gradle Android builds by installing the source template to \"%s\".\nNote that in order to make gradle builds instead of using pre-built APKs, the \"Use Gradle Build\" option should be enabled in the Android export preset."; static const String INSTALL_ANDROID_BUILD_TEMPLATE_MESSAGE = "This will set up your project for gradle Android builds by installing the source template to \"%s\".\nNote that in order to make gradle builds instead of using pre-built APKs, the \"Use Gradle Build\" option should be enabled in the Android export preset.";
bool EditorProgress::step(const String &p_state, int p_step, bool p_force_refresh) { bool EditorProgress::step(const String &p_state, int p_step, bool p_force_refresh) {
if (Thread::is_main_thread()) { if (!force_background && Thread::is_main_thread()) {
return EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); return EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh);
} else { } else {
EditorNode::progress_task_step_bg(task, p_step); EditorNode::progress_task_step_bg(task, p_step);
@ -183,17 +183,18 @@ bool EditorProgress::step(const String &p_state, int p_step, bool p_force_refres
} }
} }
EditorProgress::EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel) { EditorProgress::EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel, bool p_force_background) {
if (Thread::is_main_thread()) { if (!p_force_background && Thread::is_main_thread()) {
EditorNode::progress_add_task(p_task, p_label, p_amount, p_can_cancel); EditorNode::progress_add_task(p_task, p_label, p_amount, p_can_cancel);
} else { } else {
EditorNode::progress_add_task_bg(p_task, p_label, p_amount); EditorNode::progress_add_task_bg(p_task, p_label, p_amount);
} }
task = p_task; task = p_task;
force_background = p_force_background;
} }
EditorProgress::~EditorProgress() { EditorProgress::~EditorProgress() {
if (Thread::is_main_thread()) { if (!force_background && Thread::is_main_thread()) {
EditorNode::progress_end_task(task); EditorNode::progress_end_task(task);
} else { } else {
EditorNode::progress_end_task_bg(task); EditorNode::progress_end_task_bg(task);

View File

@ -124,9 +124,10 @@ class WindowWrapper;
struct EditorProgress { struct EditorProgress {
String task; String task;
bool force_background = false;
bool step(const String &p_state, int p_step = -1, bool p_force_refresh = true); bool step(const String &p_state, int p_step = -1, bool p_force_refresh = true);
EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel = false); EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel = false, bool p_force_background = false);
~EditorProgress(); ~EditorProgress();
}; };