mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 16:45:53 +08:00
If taking configuration snapshot before importing newer configuration fails,
offer to stop importing configuration.
This commit is contained in:
parent
56d50d7707
commit
5ba9d59307
@ -586,10 +586,12 @@ const Snapshot* take_config_snapshot_report_error(const AppConfig &app_config, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool take_config_snapshot_cancel_on_error(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment, const std::string &message)
|
bool take_config_snapshot_cancel_on_error(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment, const std::string &message, Snapshot const **psnapshot)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
SnapshotDB::singleton().take_snapshot(app_config, reason, comment);
|
const Snapshot *snapshot = &SnapshotDB::singleton().take_snapshot(app_config, reason, comment);
|
||||||
|
if (*psnapshot)
|
||||||
|
*psnapshot = snapshot;
|
||||||
return true;
|
return true;
|
||||||
} catch (std::exception &err) {
|
} catch (std::exception &err) {
|
||||||
RichMessageDialog dlg(static_cast<wxWindow*>(wxGetApp().mainframe),
|
RichMessageDialog dlg(static_cast<wxWindow*>(wxGetApp().mainframe),
|
||||||
|
@ -132,7 +132,7 @@ const Snapshot* take_config_snapshot_report_error(const AppConfig &app_config, S
|
|||||||
|
|
||||||
// Take snapshot on SnapshotDB::singleton(). If taking snapshot fails, report "message", and present a "Continue" or "Abort" buttons to respond.
|
// Take snapshot on SnapshotDB::singleton(). If taking snapshot fails, report "message", and present a "Continue" or "Abort" buttons to respond.
|
||||||
// Return true on success and on "Continue" to continue with the process (for example installation of presets).
|
// Return true on success and on "Continue" to continue with the process (for example installation of presets).
|
||||||
bool take_config_snapshot_cancel_on_error(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment, const std::string &message);
|
bool take_config_snapshot_cancel_on_error(const AppConfig &app_config, Snapshot::Reason reason, const std::string &comment, const std::string &message, Snapshot const **psnapshot = nullptr);
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
@ -977,17 +977,17 @@ std::string GUI_App::check_older_app_config(Semver current_version, bool backup)
|
|||||||
if (msg.ShowModal() == wxID_YES) {
|
if (msg.ShowModal() == wxID_YES) {
|
||||||
std::string snapshot_id;
|
std::string snapshot_id;
|
||||||
if (backup) {
|
if (backup) {
|
||||||
// configuration snapshot
|
const Config::Snapshot* snapshot{ nullptr };
|
||||||
std::string comment;
|
if (! GUI::Config::take_config_snapshot_cancel_on_error(*app_config, Config::Snapshot::SNAPSHOT_USER, "",
|
||||||
if (const Config::Snapshot* snapshot = Config::take_config_snapshot_report_error(
|
_u8L("Continue and import newer configuration?")), &snapshot)
|
||||||
*app_config,
|
return {};
|
||||||
Config::Snapshot::SNAPSHOT_USER,
|
if (snapshot) {
|
||||||
comment);
|
// Save snapshot ID before loading the alternate AppConfig, as loading the alternate AppConfig may fail.
|
||||||
snapshot != nullptr)
|
|
||||||
// Is thos correct? Save snapshot id for later, when new app config is loaded.
|
|
||||||
snapshot_id = snapshot->id;
|
snapshot_id = snapshot->id;
|
||||||
else
|
assert(! snapshot_id.empty());
|
||||||
BOOST_LOG_TRIVIAL(error) << "Failed to take congiguration snapshot: ";
|
app_config->set("on_snapshot", snapshot_id);
|
||||||
|
} else
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Failed to take congiguration snapshot";
|
||||||
}
|
}
|
||||||
|
|
||||||
// load app config from older file
|
// load app config from older file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user