From 66f998bdbf2e7013e72536d6b0d0f20bb668285e Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Mon, 14 Jan 2019 15:38:54 +0100 Subject: [PATCH] Fix of the change of the perimeters count in a vase-mode (part fix of #1649) --- src/slic3r/GUI/Field.cpp | 4 ++-- src/slic3r/GUI/Field.hpp | 1 + src/slic3r/GUI/Tab.cpp | 9 +++++++++ src/slic3r/GUI/Tab.hpp | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 2af2dc27d..3dd160432 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -436,7 +436,7 @@ void SpinCtrl::BUILD() { propagate_value(); }), temp->GetId()); - temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId()); + temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { propagate_value(); }), temp->GetId()); temp->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { @@ -472,7 +472,7 @@ void SpinCtrl::propagate_value() { if (tmp_value < 0) on_kill_focus(); - else + else if (boost::any_cast<int>(m_value) != tmp_value) on_change_field(); } diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index bcc94c7ba..3273f84c9 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -325,6 +325,7 @@ public: void set_value(const boost::any& value, bool change_event = false) { m_disable_change_event = !change_event; tmp_value = boost::any_cast<int>(value); + m_value = value; dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value); m_disable_change_event = false; } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 05852097b..d78e9c695 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1132,6 +1132,13 @@ void TabPrint::update() if (m_preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA) return; // ys_FIXME + //! Temporary workaround for the correct updates of the SpinCtrl (like "perimeters"): + // KillFocus() for the wxSpinCtrl use CallAfter function. So, + // to except the duplicate call of the update() after dialog->ShowModal(), + // let check if this process is already started. + if (is_msg_dlg_already_exist) + return; + Freeze(); double fill_density = m_config->option<ConfigOptionPercent>("fill_density")->value; @@ -1147,6 +1154,7 @@ void TabPrint::update() "- no ensure_vertical_shell_thickness\n" "\nShall I adjust those settings in order to enable Spiral Vase?")); auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Spiral Vase")), wxICON_WARNING | wxYES | wxNO); + is_msg_dlg_already_exist = true; DynamicPrintConfig new_conf = *m_config; if (dialog->ShowModal() == wxID_YES) { new_conf.set_key_value("perimeters", new ConfigOptionInt(1)); @@ -1162,6 +1170,7 @@ void TabPrint::update() } load_config(new_conf); on_value_change("fill_density", fill_density); + is_msg_dlg_already_exist = false; } if (m_config->opt_bool("wipe_tower") && m_config->opt_bool("support_material") && diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index b1ec505ab..9ec54e6eb 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -287,6 +287,7 @@ protected: class TabPrint : public Tab { + bool is_msg_dlg_already_exist {false}; public: TabPrint(wxNotebook* parent) : Tab(parent, _(L("Print Settings")), "print") {}