Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix load error popup showing on every progress dialog #96830

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4065,7 +4065,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
}
}

if (p_clear_errors) {
if (p_clear_errors && !load_errors_queued_to_display) {
load_errors->clear();
}

Expand Down Expand Up @@ -4746,14 +4746,26 @@ void EditorNode::add_io_error(const String &p_error) {
DEV_ASSERT(Thread::get_caller_id() == Thread::get_main_id());
singleton->load_errors->add_image(singleton->theme->get_icon(SNAME("Error"), EditorStringName(EditorIcons)));
singleton->load_errors->add_text(p_error + "\n");
EditorInterface::get_singleton()->popup_dialog_centered_ratio(singleton->load_error_dialog, 0.5);
// When a progress dialog is displayed, we will wait for it ot close before displaying
// the io errors to prevent the io popup to set it's parent to the progress dialog.
if (singleton->progress_dialog->is_visible()) {
singleton->load_errors_queued_to_display = true;
} else {
EditorInterface::get_singleton()->popup_dialog_centered_ratio(singleton->load_error_dialog, 0.5);
}
}

void EditorNode::add_io_warning(const String &p_warning) {
DEV_ASSERT(Thread::get_caller_id() == Thread::get_main_id());
singleton->load_errors->add_image(singleton->theme->get_icon(SNAME("Warning"), EditorStringName(EditorIcons)));
singleton->load_errors->add_text(p_warning + "\n");
EditorInterface::get_singleton()->popup_dialog_centered_ratio(singleton->load_error_dialog, 0.5);
// When a progress dialog is displayed, we will wait for it ot close before displaying
// the io errors to prevent the io popup to set it's parent to the progress dialog.
if (singleton->progress_dialog->is_visible()) {
singleton->load_errors_queued_to_display = true;
} else {
EditorInterface::get_singleton()->popup_dialog_centered_ratio(singleton->load_error_dialog, 0.5);
}
}

bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const {
Expand Down Expand Up @@ -5024,6 +5036,14 @@ void EditorNode::progress_end_task_bg(const String &p_task) {
singleton->progress_hb->end_task(p_task);
}

void EditorNode::_progress_dialog_visibility_changed() {
// Open the io errors after the progress dialog is closed.
if (load_errors_queued_to_display && !progress_dialog->is_visible()) {
EditorInterface::get_singleton()->popup_dialog_centered_ratio(singleton->load_error_dialog, 0.5);
load_errors_queued_to_display = false;
}
}

String EditorNode::_get_system_info() const {
String distribution_name = OS::get_singleton()->get_distribution_name();
if (distribution_name.is_empty()) {
Expand Down Expand Up @@ -7033,6 +7053,7 @@ EditorNode::EditorNode() {
add_child(resource_preview);
progress_dialog = memnew(ProgressDialog);
progress_dialog->set_unparent_when_invisible(true);
progress_dialog->connect(SceneStringName(visibility_changed), callable_mp(this, &EditorNode::_progress_dialog_visibility_changed));

gui_base = memnew(Panel);
add_child(gui_base);
Expand Down
3 changes: 3 additions & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ class EditorNode : public Node {

RichTextLabel *load_errors = nullptr;
AcceptDialog *load_error_dialog = nullptr;
bool load_errors_queued_to_display = false;

RichTextLabel *execute_outputs = nullptr;
AcceptDialog *execute_output_dialog = nullptr;
Expand Down Expand Up @@ -696,6 +697,8 @@ class EditorNode : public Node {

void _remove_all_not_owned_children(Node *p_node, Node *p_owner);

void _progress_dialog_visibility_changed();

protected:
friend class FileSystemDock;

Expand Down
Loading