From eebb9e3fe79cbda736bf95349c5c403ec4aef184 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 17 May 2019 17:35:15 +0200 Subject: [PATCH] Fix double wizard on incompatible bundle, for real this time --- src/slic3r/GUI/GUI_App.cpp | 11 +++++++++-- src/slic3r/Utils/PresetUpdater.cpp | 16 +++++++++------- src/slic3r/Utils/PresetUpdater.hpp | 10 +++++++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 6bdac02a0..472abd6dc 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -185,8 +185,11 @@ bool GUI_App::on_init_inner() app_conf_exists = app_config->exists(); // load settings - if (app_config->exists()) + app_conf_exists = app_config->exists(); + if (app_conf_exists) { app_config->load(); + } + app_config->set("version", SLIC3R_VERSION); app_config->save(); @@ -249,9 +252,13 @@ bool GUI_App::on_init_inner() if (once) { once = false; + PresetUpdater::UpdateResult updater_result; try { - if (!preset_updater->config_update()) { + updater_result = preset_updater->config_update(); + if (updater_result == PresetUpdater::R_INCOMPAT_EXIT) { mainframe->Close(); + } else if (updater_result == PresetUpdater::R_INCOMPAT_CONFIGURED) { + app_conf_exists = true; } } catch (const std::exception &ex) { show_error(nullptr, from_u8(ex.what())); diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index dbed76492..f34cd8db1 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -567,9 +567,9 @@ void PresetUpdater::slic3r_update_notify() } } -bool PresetUpdater::config_update() const +PresetUpdater::UpdateResult PresetUpdater::config_update() const { - if (! p->enabled_config_update) { return true; } + if (! p->enabled_config_update) { return R_NOOP; } auto updates = p->get_config_updates(); if (updates.incompats.size() > 0) { @@ -603,15 +603,15 @@ bool PresetUpdater::config_update() const p->perform_updates(std::move(updates)); GUI::ConfigWizard wizard(nullptr, GUI::ConfigWizard::RR_DATA_INCOMPAT); if (! wizard.run(GUI::wxGetApp().preset_bundle, this)) { - return false; + return R_INCOMPAT_EXIT; } GUI::wxGetApp().load_current_presets(); + return R_INCOMPAT_CONFIGURED; } else { BOOST_LOG_TRIVIAL(info) << "User wants to exit Slic3r, bye..."; - return false; + return R_INCOMPAT_EXIT; } - } - else if (updates.updates.size() > 0) { + } else if (updates.updates.size() > 0) { BOOST_LOG_TRIVIAL(info) << boost::format("Update of %1% bundles available. Asking for confirmation ...") % updates.updates.size(); std::vector updates_msg; @@ -633,14 +633,16 @@ bool PresetUpdater::config_update() const auto *app_config = GUI::wxGetApp().app_config; GUI::wxGetApp().preset_bundle->load_presets(*app_config); GUI::wxGetApp().load_current_presets(); + return R_UPDATE_INSTALLED; } else { BOOST_LOG_TRIVIAL(info) << "User refused the update"; + return R_UPDATE_REJECT; } } else { BOOST_LOG_TRIVIAL(info) << "No configuration updates available."; } - return true; + return R_NOOP; } void PresetUpdater::install_bundles_rsrc(std::vector bundles, bool snapshot) const diff --git a/src/slic3r/Utils/PresetUpdater.hpp b/src/slic3r/Utils/PresetUpdater.hpp index 4b20c18e3..7c2aab7cc 100644 --- a/src/slic3r/Utils/PresetUpdater.hpp +++ b/src/slic3r/Utils/PresetUpdater.hpp @@ -28,9 +28,17 @@ public: // If version check is enabled, check if chaced online slic3r version is newer, notify if so. void slic3r_update_notify(); + enum UpdateResult { + R_NOOP, + R_INCOMPAT_EXIT, + R_INCOMPAT_CONFIGURED, + R_UPDATE_INSTALLED, + R_UPDATE_REJECT, + }; + // If updating is enabled, check if updates are available in cache, if so, ask about installation. // A false return value implies Slic3r should exit due to incompatibility of configuration. - bool config_update() const; + UpdateResult config_update() const; // "Update" a list of bundles from resources (behaves like an online update). void install_bundles_rsrc(std::vector bundles, bool snapshot = true) const;