Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Matena <lukasmatena@seznam.cz>2019-08-19 13:55:57 +0300
committerLukas Matena <lukasmatena@seznam.cz>2019-08-19 13:55:57 +0300
commita66c59941d1ef7e9b18d7a3d3935781c491416f1 (patch)
treefd5f8d57e94b34ba766b3585e7e5c264830c60b8 /src/slic3r/GUI/AppConfig.cpp
parenteddf9321612e0cde71f466ccbc9e1cc4f6ab4442 (diff)
Better error message in case of corrupted PrusaSlicer.ini
Diffstat (limited to 'src/slic3r/GUI/AppConfig.cpp')
-rw-r--r--src/slic3r/GUI/AppConfig.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp
index dfdc79677..7ca8c3e5e 100644
--- a/src/slic3r/GUI/AppConfig.cpp
+++ b/src/slic3r/GUI/AppConfig.cpp
@@ -15,9 +15,13 @@
#include <boost/nowide/fstream.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/exceptions.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp>
+#include <wx/string.h>
+#include "I18N.hpp"
+
namespace Slic3r {
static const std::string VENDOR_PREFIX = "vendor:";
@@ -58,7 +62,7 @@ void AppConfig::set_defaults()
if (!get("use_legacy_opengl").empty())
erase("", "use_legacy_opengl");
-#if __APPLE__
+#ifdef __APPLE__
if (get("use_retina_opengl").empty())
set("use_retina_opengl", "1");
#endif
@@ -90,7 +94,14 @@ void AppConfig::load()
namespace pt = boost::property_tree;
pt::ptree tree;
boost::nowide::ifstream ifs(AppConfig::config_path());
- pt::read_ini(ifs, tree);
+ try {
+ pt::read_ini(ifs, tree);
+ } catch (pt::ptree_error& ex) {
+ // Error while parsing config file. We'll customize the error message and rethrow to be displayed.
+ throw std::runtime_error(wxString::Format(_(L("Error parsing config file, it is probably corrupted. "
+ "Try to manualy delete the file. Your user profiles will not be affected.\n\n%s\n\n%s")),
+ AppConfig::config_path(), ex.what()).ToStdString());
+ }
// 2) Parse the property_tree, extract the sections and key / value pairs.
for (const auto &section : tree) {