Follow-up of 86d7e1fb90
-> Fixed update after switching tab after editing custom g-code in settings tabs
This commit is contained in:
parent
224f3e506c
commit
908c48ae6a
2 changed files with 30 additions and 11 deletions
src/slic3r/GUI
|
@ -549,9 +549,8 @@ void MainFrame::init_tabpanel()
|
||||||
wxWindow* panel = m_tabpanel->GetCurrentPage();
|
wxWindow* panel = m_tabpanel->GetCurrentPage();
|
||||||
if (panel != nullptr) {
|
if (panel != nullptr) {
|
||||||
Tab* tab = dynamic_cast<Tab*>(panel);
|
Tab* tab = dynamic_cast<Tab*>(panel);
|
||||||
if (tab && (tab->type() == Preset::TYPE_FILAMENT || tab->type() == Preset::TYPE_PRINTER))
|
if (tab != nullptr && !tab->validate_custom_gcodes())
|
||||||
if (!tab->validate_custom_gcodes())
|
evt.Veto();
|
||||||
evt.Veto();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#endif // ENABLE_VALIDATE_CUSTOM_GCODE
|
#endif // ENABLE_VALIDATE_CUSTOM_GCODE
|
||||||
|
|
|
@ -3826,15 +3826,35 @@ void TabPrinter::apply_extruder_cnt_from_cache()
|
||||||
#if ENABLE_VALIDATE_CUSTOM_GCODE
|
#if ENABLE_VALIDATE_CUSTOM_GCODE
|
||||||
bool Tab::validate_custom_gcodes()
|
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;
|
bool valid = true;
|
||||||
if ((m_type == Preset::TYPE_FILAMENT ||
|
for (auto opt_group : m_active_page->m_optgroups) {
|
||||||
(m_type == Preset::TYPE_PRINTER && static_cast<TabPrinter*>(this)->m_printer_technology == ptFFF)) &&
|
assert(opt_group->opt_map().size() == 1);
|
||||||
m_active_page->title() == "Custom G-code") {
|
std::string key = opt_group->opt_map().begin()->first;
|
||||||
for (auto opt_group : m_active_page->m_optgroups) {
|
std::string value = boost::any_cast<std::string>(opt_group->get_value(key));
|
||||||
assert(opt_group->opt_map().size() == 1);
|
std::string config_value = m_config->opt_string(key);
|
||||||
std::string key = opt_group->opt_map().begin()->first;
|
valid &= validate_custom_gcode(opt_group->title, value);
|
||||||
valid &= validate_custom_gcode(opt_group->title, boost::any_cast<std::string>(opt_group->get_value(key)));
|
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;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue