Fix double wizard on incompatible bundle, for real this time

This commit is contained in:
Vojtech Kral 2019-05-17 17:35:15 +02:00
parent b205daa437
commit eebb9e3fe7
3 changed files with 27 additions and 10 deletions

View File

@ -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()));

View File

@ -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<GUI::MsgUpdateConfig::Update> 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<std::string> bundles, bool snapshot) const

View File

@ -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<std::string> bundles, bool snapshot = true) const;