This commit is contained in:
YuSanka 2019-08-20 13:01:51 +02:00
commit ae9b0a401c
2 changed files with 38 additions and 5 deletions

View file

@ -25,6 +25,7 @@
#include "PresetBundle.hpp" #include "PresetBundle.hpp"
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_Utils.hpp" #include "GUI_Utils.hpp"
#include "slic3r/Config/Snapshot.hpp"
#include "slic3r/Utils/PresetUpdater.hpp" #include "slic3r/Utils/PresetUpdater.hpp"
@ -32,6 +33,10 @@ namespace Slic3r {
namespace GUI { namespace GUI {
using Config::Snapshot;
using Config::SnapshotDB;
// Printer model picker GUI control // Printer model picker GUI control
struct PrinterPickerEvent : public wxEvent struct PrinterPickerEvent : public wxEvent
@ -1025,15 +1030,33 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
// Decide whether to create snapshot based on run_reason and the reset profile checkbox // Decide whether to create snapshot based on run_reason and the reset profile checkbox
bool snapshot = true; bool snapshot = true;
Snapshot::Reason snapshot_reason = Snapshot::SNAPSHOT_UPGRADE;
switch (run_reason) { switch (run_reason) {
case ConfigWizard::RR_DATA_EMPTY: snapshot = false; break; case ConfigWizard::RR_DATA_EMPTY:
case ConfigWizard::RR_DATA_LEGACY: snapshot = true; break; snapshot = false;
case ConfigWizard::RR_DATA_INCOMPAT: snapshot = false; break; // In this case snapshot is done by PresetUpdater with the appropriate reason break;
case ConfigWizard::RR_USER: snapshot = page_welcome->reset_user_profile(); break; case ConfigWizard::RR_DATA_LEGACY:
snapshot = true;
break;
case ConfigWizard::RR_DATA_INCOMPAT:
// In this case snapshot has already been taken by
// PresetUpdater with the appropriate reason
snapshot = false;
break;
case ConfigWizard::RR_USER:
snapshot = page_welcome->reset_user_profile();
snapshot_reason = Snapshot::SNAPSHOT_USER;
break;
} }
if (snapshot) {
SnapshotDB::singleton().take_snapshot(*app_config, snapshot_reason);
}
if (install_bundles.size() > 0) { if (install_bundles.size() > 0) {
// Install bundles from resources. // Install bundles from resources.
updater->install_bundles_rsrc(std::move(install_bundles), snapshot); // Don't create snapshot - we've already done that above if applicable.
updater->install_bundles_rsrc(std::move(install_bundles), false);
} else { } else {
BOOST_LOG_TRIVIAL(info) << "No bundles need to be installed from resources"; BOOST_LOG_TRIVIAL(info) << "No bundles need to be installed from resources";
} }

View file

@ -35,6 +35,10 @@ using Slic3r::GUI::Config::Snapshot;
using Slic3r::GUI::Config::SnapshotDB; using Slic3r::GUI::Config::SnapshotDB;
// FIXME: Incompat bundle resolution doesn't deal with inherited user presets
namespace Slic3r { namespace Slic3r {
@ -624,11 +628,17 @@ PresetUpdater::UpdateResult PresetUpdater::config_update() const
const auto res = dlg.ShowModal(); const auto res = dlg.ShowModal();
if (res == wxID_REPLACE) { if (res == wxID_REPLACE) {
BOOST_LOG_TRIVIAL(info) << "User wants to re-configure..."; BOOST_LOG_TRIVIAL(info) << "User wants to re-configure...";
// This effectively removes the incompatible bundles:
// (snapshot is taken beforehand)
p->perform_updates(std::move(updates)); p->perform_updates(std::move(updates));
GUI::ConfigWizard wizard(nullptr, GUI::ConfigWizard::RR_DATA_INCOMPAT); GUI::ConfigWizard wizard(nullptr, GUI::ConfigWizard::RR_DATA_INCOMPAT);
if (! wizard.run(GUI::wxGetApp().preset_bundle, this)) { if (! wizard.run(GUI::wxGetApp().preset_bundle, this)) {
return R_INCOMPAT_EXIT; return R_INCOMPAT_EXIT;
} }
GUI::wxGetApp().load_current_presets(); GUI::wxGetApp().load_current_presets();
return R_INCOMPAT_CONFIGURED; return R_INCOMPAT_CONFIGURED;
} else { } else {