Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2020-03-12 18:05:39 +0300
committerbubnikv <bubnikv@gmail.com>2020-03-12 18:05:39 +0300
commit1d5249f9b03f3b793760ce6bdcb2fe9b6ce84e7d (patch)
treefeb7599f7e2cb23f12653f821c0c674c6acc2c45 /src/slic3r/GUI
parent6866c2bdd478022daa4527ae3b147be0e4f07810 (diff)
Fix of #3660 : Background processing restart and error messages
are suppressed while tracking a pop-up menu.
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r--src/slic3r/GUI/Plater.cpp26
-rw-r--r--src/slic3r/GUI/Plater.hpp10
2 files changed, 35 insertions, 1 deletions
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index 461416869..1ffc2e872 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -3725,7 +3725,12 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
wxString message = evt.GetString();
if (message.IsEmpty())
message = _(L("Export failed"));
- show_error(q, message);
+ if (q->m_tracking_popup_menu)
+ // We don't want to pop-up a message box when tracking a pop-up menu.
+ // We postpone the error message instead.
+ q->m_tracking_popup_menu_error_message = message;
+ else
+ show_error(q, message);
this->statusbar()->set_status_text(message);
}
if (canceled)
@@ -5729,6 +5734,25 @@ const UndoRedo::Stack& Plater::undo_redo_stack_main() const { return p->undo_red
void Plater::enter_gizmos_stack() { p->enter_gizmos_stack(); }
void Plater::leave_gizmos_stack() { p->leave_gizmos_stack(); }
+// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
+bool Plater::PopupMenu(wxMenu *menu, const wxPoint& pos)
+{
+ // Don't want to wake up and trigger reslicing while tracking the pop-up menu.
+ SuppressBackgroundProcessingUpdate sbpu;
+ // When tracking a pop-up menu, postpone error messages from the slicing result.
+ m_tracking_popup_menu = true;
+ bool out = this->wxPanel::PopupMenu(menu, pos);
+ m_tracking_popup_menu = false;
+ if (! m_tracking_popup_menu_error_message.empty()) {
+ // Don't know whether the CallAfter is necessary, but it should not hurt.
+ // The menus likely sends out some commands, so we may be safer if the dialog is shown after the menu command is processed.
+ wxString message = std::move(m_tracking_popup_menu_error_message);
+ wxTheApp->CallAfter([message, this]() { show_error(this, message); });
+ m_tracking_popup_menu_error_message.clear();
+ }
+ return out;
+}
+
SuppressBackgroundProcessingUpdate::SuppressBackgroundProcessingUpdate() :
m_was_running(wxGetApp().plater()->is_background_process_running())
{
diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp
index 89603f703..6fa2a1207 100644
--- a/src/slic3r/GUI/Plater.hpp
+++ b/src/slic3r/GUI/Plater.hpp
@@ -319,10 +319,20 @@ public:
Plater *m_plater;
};
+ // Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
+ bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition);
+ bool PopupMenu(wxMenu *menu, int x, int y) { return this->PopupMenu(menu, wxPoint(x, y)); }
+
private:
struct priv;
std::unique_ptr<priv> p;
+ // Set true during PopupMenu() tracking to suppress immediate error message boxes.
+ // The error messages are collected to m_tracking_popup_menu_error_message instead and these error messages
+ // are shown after the pop-up dialog closes.
+ bool m_tracking_popup_menu = false;
+ wxString m_tracking_popup_menu_error_message;
+
void suppress_snapshots();
void allow_snapshots();