Merge branch 'master' into fs_emboss
# Conflicts: # src/libslic3r/Geometry.cpp # src/slic3r/GUI/Gizmos/GLGizmoBase.cpp # src/slic3r/GUI/Gizmos/GLGizmoMove.cpp # src/slic3r/GUI/Gizmos/GLGizmoMove.hpp # src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp # src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp # src/slic3r/GUI/Gizmos/GLGizmoScale.cpp # src/slic3r/GUI/Gizmos/GLGizmoScale.hpp # src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp # src/slic3r/GUI/ImGuiWrapper.cpp # src/slic3r/GUI/ImGuiWrapper.hpp # src/slic3r/GUI/Selection.cpp # tests/slic3rutils/slic3r_jobs_tests.cpp
This commit is contained in:
commit
a50d93cd66
327 changed files with 781602 additions and 153573 deletions
|
@ -44,6 +44,10 @@ const std::string AppConfig::SECTION_FONT = "font";
|
|||
void AppConfig::reset()
|
||||
{
|
||||
m_storage.clear();
|
||||
m_vendors.clear();
|
||||
m_dirty = false;
|
||||
m_orig_version = Semver::invalid();
|
||||
m_legacy_datadir = false;
|
||||
set_defaults();
|
||||
};
|
||||
|
||||
|
@ -147,6 +151,11 @@ void AppConfig::set_defaults()
|
|||
if (get("order_volumes").empty())
|
||||
set("order_volumes", "1");
|
||||
|
||||
#if ENABLE_SHOW_NON_MANIFOLD_EDGES
|
||||
if (get("non_manifold_edges").empty())
|
||||
set("non_manifold_edges", "1");
|
||||
#endif // ENABLE_SHOW_NON_MANIFOLD_EDGES
|
||||
|
||||
if (get("clear_undo_redo_stack_on_new_project").empty())
|
||||
set("clear_undo_redo_stack_on_new_project", "1");
|
||||
}
|
||||
|
@ -172,6 +181,9 @@ void AppConfig::set_defaults()
|
|||
if (get("show_splash_screen").empty())
|
||||
set("show_splash_screen", "1");
|
||||
|
||||
if (get("restore_win_position").empty())
|
||||
set("restore_win_position", "1"); // allowed values - "1", "0", "crashed_at_..."
|
||||
|
||||
if (get("show_hints").empty())
|
||||
set("show_hints", "1");
|
||||
|
||||
|
@ -244,8 +256,10 @@ static bool verify_config_file_checksum(boost::nowide::ifstream &ifs)
|
|||
}
|
||||
#endif
|
||||
|
||||
std::string AppConfig::load()
|
||||
std::string AppConfig::load(const std::string &path)
|
||||
{
|
||||
this->reset();
|
||||
|
||||
// 1) Read the complete config file into a boost::property_tree.
|
||||
namespace pt = boost::property_tree;
|
||||
pt::ptree tree;
|
||||
|
@ -253,11 +267,11 @@ std::string AppConfig::load()
|
|||
bool recovered = false;
|
||||
|
||||
try {
|
||||
ifs.open(AppConfig::loading_path());
|
||||
ifs.open(path);
|
||||
#ifdef WIN32
|
||||
// Verify the checksum of the config file without taking just for debugging purpose.
|
||||
if (!verify_config_file_checksum(ifs))
|
||||
BOOST_LOG_TRIVIAL(info) << "The configuration file " << AppConfig::loading_path() <<
|
||||
BOOST_LOG_TRIVIAL(info) << "The configuration file " << path <<
|
||||
" has a wrong MD5 checksum or the checksum is missing. This may indicate a file corruption or a harmless user edit.";
|
||||
|
||||
ifs.seekg(0, boost::nowide::ifstream::beg);
|
||||
|
@ -267,32 +281,32 @@ std::string AppConfig::load()
|
|||
#ifdef WIN32
|
||||
// The configuration file is corrupted, try replacing it with the backup configuration.
|
||||
ifs.close();
|
||||
std::string backup_path = (boost::format("%1%.bak") % AppConfig::loading_path()).str();
|
||||
std::string backup_path = (boost::format("%1%.bak") % path).str();
|
||||
if (boost::filesystem::exists(backup_path)) {
|
||||
// Compute checksum of the configuration backup file and try to load configuration from it when the checksum is correct.
|
||||
boost::nowide::ifstream backup_ifs(backup_path);
|
||||
if (!verify_config_file_checksum(backup_ifs)) {
|
||||
BOOST_LOG_TRIVIAL(error) << format("Both \"%1%\" and \"%2%\" are corrupted. It isn't possible to restore configuration from the backup.", AppConfig::loading_path(), backup_path);
|
||||
BOOST_LOG_TRIVIAL(error) << format("Both \"%1%\" and \"%2%\" are corrupted. It isn't possible to restore configuration from the backup.", path, backup_path);
|
||||
backup_ifs.close();
|
||||
boost::filesystem::remove(backup_path);
|
||||
} else if (std::string error_message; copy_file(backup_path, AppConfig::loading_path(), error_message, false) != SUCCESS) {
|
||||
BOOST_LOG_TRIVIAL(error) << format("Configuration file \"%1%\" is corrupted. Failed to restore from backup \"%2%\": %3%", AppConfig::loading_path(), backup_path, error_message);
|
||||
} else if (std::string error_message; copy_file(backup_path, path, error_message, false) != SUCCESS) {
|
||||
BOOST_LOG_TRIVIAL(error) << format("Configuration file \"%1%\" is corrupted. Failed to restore from backup \"%2%\": %3%", path, backup_path, error_message);
|
||||
backup_ifs.close();
|
||||
boost::filesystem::remove(backup_path);
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << format("Configuration file \"%1%\" was corrupted. It has been succesfully restored from the backup \"%2%\".", AppConfig::loading_path(), backup_path);
|
||||
BOOST_LOG_TRIVIAL(info) << format("Configuration file \"%1%\" was corrupted. It has been succesfully restored from the backup \"%2%\".", path, backup_path);
|
||||
// Try parse configuration file after restore from backup.
|
||||
try {
|
||||
ifs.open(AppConfig::loading_path());
|
||||
ifs.open(path);
|
||||
pt::read_ini(ifs, tree);
|
||||
recovered = true;
|
||||
} catch (pt::ptree_error& ex) {
|
||||
BOOST_LOG_TRIVIAL(info) << format("Failed to parse configuration file \"%1%\" after it has been restored from backup: %2%", AppConfig::loading_path(), ex.what());
|
||||
BOOST_LOG_TRIVIAL(info) << format("Failed to parse configuration file \"%1%\" after it has been restored from backup: %2%", path, ex.what());
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif // WIN32
|
||||
BOOST_LOG_TRIVIAL(info) << format("Failed to parse configuration file \"%1%\": %2%", AppConfig::loading_path(), ex.what());
|
||||
BOOST_LOG_TRIVIAL(info) << format("Failed to parse configuration file \"%1%\": %2%", path, ex.what());
|
||||
if (! recovered) {
|
||||
// Report the initial error of parsing PrusaSlicer.ini.
|
||||
// Error while parsing config file. We'll customize the error message and rethrow to be displayed.
|
||||
|
@ -368,6 +382,11 @@ std::string AppConfig::load()
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string AppConfig::load()
|
||||
{
|
||||
return this->load(AppConfig::config_path());
|
||||
}
|
||||
|
||||
void AppConfig::save()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue