From 5010f0c2af6af1cffa580cc7e6d37c6ef67a9ec9 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 7 Jan 2022 18:18:06 +0100 Subject: [PATCH] Further debugging of issue 7583 --- src/slic3r/GUI/ConfigWizard.cpp | 2 ++ src/slic3r/GUI/GUI_App.cpp | 16 +++++++++++++++- src/slic3r/GUI/UnsavedChangesDialog.cpp | 11 +++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 514a06b725..c14cb985e7 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -2722,11 +2722,13 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese if (!check_unsaved_preset_changes) { if ((check_unsaved_preset_changes = !preferred_model.empty())) { header = _L("A new Printer was installed and it will be activated."); + BOOST_LOG_TRIVIAL(error) << "ConfigWizard::priv::apply_config 15a"; if (!wxGetApp().check_and_keep_current_preset_changes(caption, header, act_btns, &apply_keeped_changes)) return false; } else if ((check_unsaved_preset_changes = enabled_vendors_old != enabled_vendors)) { header = _L("Some Printers were uninstalled."); + BOOST_LOG_TRIVIAL(error) << "ConfigWizard::priv::apply_config 15b"; if (!wxGetApp().check_and_keep_current_preset_changes(caption, header, act_btns, &apply_keeped_changes)) return false; } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1858044ae8..57efd2a540 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2497,14 +2497,23 @@ void GUI_App::apply_keeped_preset_modifications() // Note: no_nullptr postponed_apply_of_keeped_changes indicates that thie function is called after ConfigWizard is closed bool GUI_App::check_and_keep_current_preset_changes(const wxString& caption, const wxString& header, int action_buttons, bool* postponed_apply_of_keeped_changes/* = nullptr*/) { + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 1"; + if (has_current_preset_changes()) { + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 2"; bool is_called_from_configwizard = postponed_apply_of_keeped_changes != nullptr; const std::string app_config_key = is_called_from_configwizard ? "" : "default_action_on_new_project"; + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 3"; UnsavedChangesDialog dlg(caption, header, app_config_key, action_buttons); + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 4"; std::string act = app_config_key.empty() ? "none" : wxGetApp().app_config->get(app_config_key); + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 5"; if (act == "none" && dlg.ShowModal() == wxID_CANCEL) return false; + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 6"; + + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 7"; auto reset_modifications = [this, is_called_from_configwizard]() { if (is_called_from_configwizard) @@ -2518,10 +2527,15 @@ bool GUI_App::check_and_keep_current_preset_changes(const wxString& caption, con load_current_presets(false); }; - if (dlg.discard()) + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 8"; + + if (dlg.discard()) { reset_modifications(); + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 9"; + } else // save selected changes { + BOOST_LOG_TRIVIAL(error) << "GUI_App::check_and_keep_current_preset_changes 10"; const auto& preset_names_and_types = dlg.get_names_and_types(); if (dlg.save_preset()) { for (const std::pair& nt : preset_names_and_types) diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 3afedbd688..4fe6770a52 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -772,17 +772,28 @@ UnsavedChangesDialog::UnsavedChangesDialog(const wxString& caption, const wxStri m_app_config_key(app_config_key), m_buttons(act_buttons) { + BOOST_LOG_TRIVIAL(error) << "UnsavedChangesDialog::UnsavedChangesDialog 1"; + build(Preset::TYPE_INVALID, nullptr, "", header); + BOOST_LOG_TRIVIAL(error) << "UnsavedChangesDialog::UnsavedChangesDialog 2"; + const std::string& def_action = m_app_config_key.empty() ? none : wxGetApp().app_config->get(m_app_config_key); + + BOOST_LOG_TRIVIAL(error) << "UnsavedChangesDialog::UnsavedChangesDialog 3"; + if (def_action == none) this->CenterOnScreen(); else { + BOOST_LOG_TRIVIAL(error) << "UnsavedChangesDialog::UnsavedChangesDialog 4"; + m_exit_action = def_action == ActTransfer ? Action::Transfer : def_action == ActSave ? Action::Save : Action::Discard; if (m_exit_action != Action::Discard) save(nullptr, m_exit_action == Action::Save); } + + BOOST_LOG_TRIVIAL(error) << "UnsavedChangesDialog::UnsavedChangesDialog 5"; } UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset)