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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/slic3r')
-rw-r--r--src/slic3r/GUI/MainFrame.cpp5
-rw-r--r--src/slic3r/GUI/Tab.cpp36
2 files changed, 30 insertions, 11 deletions
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 91357ff6c..6b0dd1ad5 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -549,9 +549,8 @@ void MainFrame::init_tabpanel()
wxWindow* panel = m_tabpanel->GetCurrentPage();
if (panel != nullptr) {
Tab* tab = dynamic_cast<Tab*>(panel);
- if (tab && (tab->type() == Preset::TYPE_FILAMENT || tab->type() == Preset::TYPE_PRINTER))
- if (!tab->validate_custom_gcodes())
- evt.Veto();
+ if (tab != nullptr && !tab->validate_custom_gcodes())
+ evt.Veto();
}
});
#endif // ENABLE_VALIDATE_CUSTOM_GCODE
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index cf1879bb1..eeb420e3e 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -3826,15 +3826,35 @@ void TabPrinter::apply_extruder_cnt_from_cache()
#if ENABLE_VALIDATE_CUSTOM_GCODE
bool Tab::validate_custom_gcodes()
{
+ if (m_type != Preset::TYPE_FILAMENT &&
+ (m_type != Preset::TYPE_PRINTER || static_cast<TabPrinter*>(this)->m_printer_technology != ptFFF))
+ return true;
+ if (m_active_page->title() != L("Custom G-code"))
+ return true;
+
bool valid = true;
- if ((m_type == Preset::TYPE_FILAMENT ||
- (m_type == Preset::TYPE_PRINTER && static_cast<TabPrinter*>(this)->m_printer_technology == ptFFF)) &&
- m_active_page->title() == "Custom G-code") {
- for (auto opt_group : m_active_page->m_optgroups) {
- assert(opt_group->opt_map().size() == 1);
- std::string key = opt_group->opt_map().begin()->first;
- valid &= validate_custom_gcode(opt_group->title, boost::any_cast<std::string>(opt_group->get_value(key)));
- }
+ for (auto opt_group : m_active_page->m_optgroups) {
+ assert(opt_group->opt_map().size() == 1);
+ std::string key = opt_group->opt_map().begin()->first;
+ std::string value = boost::any_cast<std::string>(opt_group->get_value(key));
+ std::string config_value = m_config->opt_string(key);
+ valid &= validate_custom_gcode(opt_group->title, value);
+ Field* field = opt_group->get_field(key);
+ TextCtrl* text_ctrl = dynamic_cast<TextCtrl*>(field);
+ if (text_ctrl != nullptr && text_ctrl->m_on_change != nullptr && !text_ctrl->m_disable_change_event) {
+ Slic3r::GUI::t_change callback = opt_group->m_on_change;
+ // temporary disable the opt_group->m_on_change callback to avoid multiple validations
+ opt_group->m_on_change = nullptr;
+ text_ctrl->m_on_change(key, value);
+ // restore the opt_group->m_on_change callback
+ opt_group->m_on_change = callback;
+
+ update_dirty();
+ on_value_change(key, value);
+ }
+
+ if (!valid)
+ break;
}
return valid;
}