From f31a2db495d3900579b9d0f49943504539ea5ea6 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 12 Nov 2021 17:05:19 +0100 Subject: [PATCH] Fix of Changing purge volumes doesn't set project as unsaved #7265 --- src/slic3r/GUI/Plater.cpp | 1 + src/slic3r/GUI/ProjectDirtyStateManager.cpp | 15 ++++++++++----- src/slic3r/GUI/ProjectDirtyStateManager.hpp | 5 ++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 9f83587f4..cc88e8b32 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -457,6 +457,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) : std::vector extruders = dlg.get_extruders(); (project_config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(), matrix.end()); (project_config.option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(), extruders.end()); + wxGetApp().plater()->update_project_dirty_from_presets(); wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent)); } })); diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.cpp b/src/slic3r/GUI/ProjectDirtyStateManager.cpp index ecf596634..c79ac0c39 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.cpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.cpp @@ -26,12 +26,14 @@ void ProjectDirtyStateManager::update_from_presets() { m_presets_dirty = false; // check switching of the presets only for exist/loaded project, but not for new - if (!wxGetApp().plater()->get_project_filename().IsEmpty()) { - for (const auto& [type, name] : wxGetApp().get_selected_presets()) + GUI_App &app = wxGetApp(); + if (!app.plater()->get_project_filename().IsEmpty()) { + for (const auto& [type, name] : app.get_selected_presets()) m_presets_dirty |= !m_initial_presets[type].empty() && m_initial_presets[type] != name; } - m_presets_dirty |= wxGetApp().has_unsaved_preset_changes(); - wxGetApp().mainframe->update_title(); + m_presets_dirty |= app.has_unsaved_preset_changes(); + m_project_config_dirty = m_initial_project_config != app.preset_bundle->project_config; + app.mainframe->update_title(); } void ProjectDirtyStateManager::reset_after_save() @@ -39,14 +41,17 @@ void ProjectDirtyStateManager::reset_after_save() this->reset_initial_presets(); m_plater_dirty = false; m_presets_dirty = false; + m_project_config_dirty = false; wxGetApp().mainframe->update_title(); } void ProjectDirtyStateManager::reset_initial_presets() { m_initial_presets.fill(std::string{}); - for (const auto& [type, name] : wxGetApp().get_selected_presets()) + GUI_App &app = wxGetApp(); + for (const auto& [type, name] : app.get_selected_presets()) m_initial_presets[type] = name; + m_initial_project_config = app.preset_bundle->project_config; } #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.hpp b/src/slic3r/GUI/ProjectDirtyStateManager.hpp index 574e6912e..29ba4eec0 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.hpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.hpp @@ -14,7 +14,7 @@ public: void reset_after_save(); void reset_initial_presets(); - bool is_dirty() const { return m_plater_dirty || m_presets_dirty; } + bool is_dirty() const { return m_plater_dirty || m_project_config_dirty || m_presets_dirty; } #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW void render_debug_window() const; @@ -25,8 +25,11 @@ private: bool m_plater_dirty { false }; // Do the presets indicate the project is dirty? bool m_presets_dirty { false }; + // Is the project config dirty? + bool m_project_config_dirty { false }; // Keeps track of preset names selected at the time of last project save. std::array m_initial_presets; + DynamicPrintConfig m_initial_project_config; }; } // namespace GUI