SubstitutionManager: Follow-up 2b25f55f8 - Fixed a crash.

(Added missed cleaning of the m_chb_match_single_lines on Delete All substitutions)

+ Added missed Layout on add substitution

+ EditGCodeDialog: Deleted unused code caused compilation warning.
This commit is contained in:
YuSanka 2023-09-22 15:42:30 +02:00
parent fc03b9f36c
commit fd7d7e1ae5
2 changed files with 5 additions and 2 deletions

View File

@ -277,7 +277,6 @@ void EditGCodeDialog::add_selected_value_to_gcode()
if (val.IsEmpty()) if (val.IsEmpty())
return; return;
const long pos = m_gcode_editor->GetInsertionPoint();
m_gcode_editor->WriteText(m_gcode_editor->GetInsertionPoint() == m_gcode_editor->GetLastPosition() ? "\n" + val : val); m_gcode_editor->WriteText(m_gcode_editor->GetInsertionPoint() == m_gcode_editor->GetLastPosition() ? "\n" + val : val);
if (val.Last() == ']') { if (val.Last() == ']') {

View File

@ -4735,6 +4735,7 @@ void SubstitutionManager::update_from_config()
if (m_substitutions == subst && m_grid_sizer->IsShown(1)) { if (m_substitutions == subst && m_grid_sizer->IsShown(1)) {
// just update visibility for chb_match_single_lines // just update visibility for chb_match_single_lines
int subst_id = 0; int subst_id = 0;
assert(m_chb_match_single_lines.size() == size_t(subst.size()/4));
for (size_t i = 0; i < subst.size(); i += 4) { for (size_t i = 0; i < subst.size(); i += 4) {
const std::string& params = subst[i + 2]; const std::string& params = subst[i + 2];
const bool regexp = strchr(params.c_str(), 'r') != nullptr || strchr(params.c_str(), 'R') != nullptr; const bool regexp = strchr(params.c_str(), 'r') != nullptr || strchr(params.c_str(), 'R') != nullptr;
@ -4772,8 +4773,10 @@ void SubstitutionManager::delete_all()
m_config->option<ConfigOptionStrings>("gcode_substitutions")->values.clear(); m_config->option<ConfigOptionStrings>("gcode_substitutions")->values.clear();
call_ui_update(); call_ui_update();
if (!m_grid_sizer->IsEmpty()) if (!m_grid_sizer->IsEmpty()) {
m_grid_sizer->Clear(true); m_grid_sizer->Clear(true);
m_chb_match_single_lines.clear();
}
m_parent->GetParent()->Layout(); m_parent->GetParent()->Layout();
} }
@ -4839,6 +4842,7 @@ wxSizer* TabPrint::create_substitutions_widget(wxWindow* parent)
m_subst_manager.init(m_config, parent, grid_sizer); m_subst_manager.init(m_config, parent, grid_sizer);
m_subst_manager.set_cb_edited_substitution([this]() { m_subst_manager.set_cb_edited_substitution([this]() {
update_dirty(); update_dirty();
Layout();
wxGetApp().mainframe->on_config_changed(m_config); // invalidate print wxGetApp().mainframe->on_config_changed(m_config); // invalidate print
}); });
m_subst_manager.set_cb_hide_delete_all_btn([this]() { m_subst_manager.set_cb_hide_delete_all_btn([this]() {