diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 6a900714ea..18a71f681d 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -220,15 +220,19 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S return; } - if (m_plater != nullptr && !m_plater->save_project_if_dirty()) { - event.Veto(); - return; + if (m_plater != nullptr) { + int saved_project = m_plater->save_project_if_dirty(); + if (saved_project == wxID_CANCEL) { + event.Veto(); + return; + } + // check unsaved changes only if project wasn't saved + else if (saved_project == wxID_NO && event.CanVeto() && !wxGetApp().check_and_save_current_preset_changes()) { + event.Veto(); + return; + } } - if (event.CanVeto() && !wxGetApp().check_and_save_current_preset_changes()) { - event.Veto(); - return; - } if (event.CanVeto() && !wxGetApp().check_print_host_queue()) { event.Veto(); return; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index fc77e9b9d8..b5a2292761 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1576,20 +1576,19 @@ struct Plater::priv bool is_project_dirty() const { return dirty_state.is_dirty(); } void update_project_dirty_from_presets() { dirty_state.update_from_presets(); } - bool save_project_if_dirty() { + int save_project_if_dirty() { + int res = wxID_NO; if (dirty_state.is_dirty()) { MainFrame* mainframe = wxGetApp().mainframe; if (mainframe->can_save_as()) { //wxMessageDialog dlg(mainframe, _L("Do you want to save the changes to the current project ?"), wxString(SLIC3R_APP_NAME), wxYES_NO | wxCANCEL); MessageDialog dlg(mainframe, _L("Do you want to save the changes to the current project ?"), wxString(SLIC3R_APP_NAME), wxYES_NO | wxCANCEL); - int res = dlg.ShowModal(); + res = dlg.ShowModal(); if (res == wxID_YES) mainframe->save_project_as(wxGetApp().plater()->get_project_filename()); - else if (res == wxID_CANCEL) - return false; } } - return true; + return res; } void reset_project_dirty_after_save() { dirty_state.reset_after_save(); } void reset_project_dirty_initial_presets() { dirty_state.reset_initial_presets(); } @@ -4647,7 +4646,7 @@ Plater::Plater(wxWindow *parent, MainFrame *main_frame) bool Plater::is_project_dirty() const { return p->is_project_dirty(); } void Plater::update_project_dirty_from_presets() { p->update_project_dirty_from_presets(); } -bool Plater::save_project_if_dirty() { return p->save_project_if_dirty(); } +int Plater::save_project_if_dirty() { return p->save_project_if_dirty(); } void Plater::reset_project_dirty_after_save() { p->reset_project_dirty_after_save(); } void Plater::reset_project_dirty_initial_presets() { p->reset_project_dirty_initial_presets(); } #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 2b1a83ba28..3556756e23 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -140,7 +140,7 @@ public: bool is_project_dirty() const; void update_project_dirty_from_presets(); - bool save_project_if_dirty(); + int save_project_if_dirty(); void reset_project_dirty_after_save(); void reset_project_dirty_initial_presets(); #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW