From ffea00454e51d98a5a6888f67f8d666f7600ca67 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 7 Dec 2020 19:47:37 +0100 Subject: [PATCH] Fixed missing include. --- src/slic3r/Config/Snapshot.cpp | 21 +++++++++++++-------- src/slic3r/GUI/Field.cpp | 1 + src/slic3r/GUI/GUI_App.cpp | 15 +++++++++------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/slic3r/Config/Snapshot.cpp b/src/slic3r/Config/Snapshot.cpp index 54d1dea577..900172d3eb 100644 --- a/src/slic3r/Config/Snapshot.cpp +++ b/src/slic3r/Config/Snapshot.cpp @@ -264,12 +264,14 @@ bool Snapshot::equal_to_active(const AppConfig &app_config) const boost::filesystem::path path1 = data_dir / subdir; boost::filesystem::path path2 = snapshot_dir / subdir; std::vector files1, files2; - for (auto &dir_entry : boost::filesystem::directory_iterator(path1)) - if (Slic3r::is_ini_file(dir_entry)) - files1.emplace_back(dir_entry.path().filename().string()); - for (auto &dir_entry : boost::filesystem::directory_iterator(path2)) - if (Slic3r::is_ini_file(dir_entry)) - files2.emplace_back(dir_entry.path().filename().string()); + if (boost::filesystem::is_directory(path1)) + for (auto &dir_entry : boost::filesystem::directory_iterator(path1)) + if (Slic3r::is_ini_file(dir_entry)) + files1.emplace_back(dir_entry.path().filename().string()); + if (boost::filesystem::is_directory(path2)) + for (auto &dir_entry : boost::filesystem::directory_iterator(path2)) + if (Slic3r::is_ini_file(dir_entry)) + files2.emplace_back(dir_entry.path().filename().string()); std::sort(files1.begin(), files1.end()); std::sort(files2.begin(), files2.end()); if (files1 != files2) @@ -459,8 +461,11 @@ void SnapshotDB::restore_snapshot(const Snapshot &snapshot, AppConfig &app_confi boost::filesystem::path snapshot_dir = snapshot_db_dir / snapshot.id; // Remove existing ini files and restore the ini files from the snapshot. for (const char *subdir : snapshot_subdirs) { - delete_existing_ini_files(data_dir / subdir); - copy_config_dir_single_level(snapshot_dir / subdir, data_dir / subdir); + boost::filesystem::path src = snapshot_dir / subdir; + boost::filesystem::path dst = data_dir / subdir; + delete_existing_ini_files(dst); + if (boost::filesystem::is_directory(src)) + copy_config_dir_single_level(src, dst); } // Update AppConfig with the selections of the print / sla_print / filament / sla_material / printer profiles // and about the installed printer types and variants. diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 7c70c16351..359d9d97e4 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -5,6 +5,7 @@ #include "wxExtensions.hpp" #include "Plater.hpp" #include "MainFrame.hpp" +#include "format.hpp" #include "libslic3r/PrintConfig.hpp" diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 84232e2d33..74e6d3746e 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1582,13 +1582,16 @@ void GUI_App::add_config_menu(wxMenuBar *menu) ConfigSnapshotDialog dlg(Slic3r::GUI::Config::SnapshotDB::singleton(), on_snapshot); dlg.ShowModal(); if (!dlg.snapshot_to_activate().empty()) { - if (!Config::SnapshotDB::singleton().is_on_snapshot(*app_config)) + if (! Config::SnapshotDB::singleton().is_on_snapshot(*app_config)) Config::SnapshotDB::singleton().take_snapshot(*app_config, Config::Snapshot::SNAPSHOT_BEFORE_ROLLBACK); - app_config->set("on_snapshot", - Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *app_config).id); - preset_bundle->load_presets(*app_config); - // Load the currently selected preset into the GUI, update the preset selection box. - load_current_presets(); + try { + app_config->set("on_snapshot", Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *app_config).id); + preset_bundle->load_presets(*app_config); + // Load the currently selected preset into the GUI, update the preset selection box. + load_current_presets(); + } catch (std::exception &ex) { + GUI::show_error(nullptr, _L("Failed to activate configuration snapshot.") + "\n" + into_u8(ex.what())); + } } } break;