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:
authorVojtech Kral <vojtech@kral.hk>2019-02-14 17:28:18 +0300
committerVojtech Kral <vojtech@kral.hk>2019-02-15 17:38:13 +0300
commitd8c7966bec2d7e7fb1a2cea7f0aeda3673794dce (patch)
tree2cd63bc36667488ec47cfeba2312b33bb5a7227d /src/slic3r
parenteb643a1f52d249220facafa7175b69c34496c7e0 (diff)
PresetUpdater: Don't fail as hard if version not found in index #1821
GUI_App: Add OnExceptionInMainLoop handler
Diffstat (limited to 'src/slic3r')
-rw-r--r--src/slic3r/GUI/GUI_App.cpp20
-rw-r--r--src/slic3r/GUI/GUI_App.hpp2
-rw-r--r--src/slic3r/Utils/PresetUpdater.cpp44
3 files changed, 51 insertions, 15 deletions
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 38a5f3387..b5d56bb54 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -3,8 +3,10 @@
#include "GUI_ObjectManipulation.hpp"
#include "I18N.hpp"
+#include <exception>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/log/trivial.hpp>
#include <wx/stdpaths.h>
#include <wx/imagpng.h>
@@ -181,7 +183,6 @@ bool GUI_App::OnInit()
mainframe->Close();
} catch (const std::exception &ex) {
show_error(nullptr, ex.what());
- mainframe->Close();
}
});
@@ -681,6 +682,23 @@ void GUI_App::load_current_presets()
}
}
+bool GUI_App::OnExceptionInMainLoop()
+{
+ try {
+ throw;
+ } catch (const std::exception &ex) {
+ const std::string error = (boost::format("Uncaught exception: %1%") % ex.what()).str();
+ BOOST_LOG_TRIVIAL(error) << error;
+ show_error(nullptr, from_u8(error));
+ } catch (...) {
+ const char *error = "Uncaught exception: Unknown error";
+ BOOST_LOG_TRIVIAL(error) << error;
+ show_error(nullptr, from_u8(error));
+ }
+
+ return false;
+}
+
#ifdef __APPLE__
// wxWidgets override to get an event on open files.
void GUI_App::MacOpenFiles(const wxArrayString &fileNames)
diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp
index 43938b66a..5fc691e8a 100644
--- a/src/slic3r/GUI/GUI_App.hpp
+++ b/src/slic3r/GUI/GUI_App.hpp
@@ -137,6 +137,8 @@ public:
bool checked_tab(Tab* tab);
void load_current_presets();
+ virtual bool OnExceptionInMainLoop();
+
#ifdef __APPLE__
// wxWidgets override to get an event on open files.
void MacOpenFiles(const wxArrayString &fileNames) override;
diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp
index a22d463fb..1fd6d3f4a 100644
--- a/src/slic3r/Utils/PresetUpdater.cpp
+++ b/src/slic3r/Utils/PresetUpdater.cpp
@@ -90,9 +90,23 @@ struct Updates
std::vector<Update> updates;
};
+static Semver get_slic3r_version()
+{
+ auto res = Semver::parse(SLIC3R_VERSION);
+
+ if (! res) {
+ const char *error = "Could not parse Slic3r version string: " SLIC3R_VERSION;
+ BOOST_LOG_TRIVIAL(error) << error;
+ throw std::runtime_error(error);
+ }
+
+ return *res;
+}
+
struct PresetUpdater::priv
{
+ const Semver ver_slic3r;
std::vector<Index> index_db;
bool enabled_version_check;
@@ -122,12 +136,13 @@ struct PresetUpdater::priv
static void copy_file(const fs::path &from, const fs::path &to);
};
-PresetUpdater::priv::priv() :
- had_config_update(false),
- cache_path(fs::path(Slic3r::data_dir()) / "cache"),
- rsrc_path(fs::path(resources_dir()) / "profiles"),
- vendor_path(fs::path(Slic3r::data_dir()) / "vendor"),
- cancel(false)
+PresetUpdater::priv::priv()
+ : ver_slic3r(get_slic3r_version())
+ , had_config_update(false)
+ , cache_path(fs::path(Slic3r::data_dir()) / "cache")
+ , rsrc_path(fs::path(resources_dir()) / "profiles")
+ , vendor_path(fs::path(Slic3r::data_dir()) / "vendor")
+ , cancel(false)
{
set_download_prefs(GUI::wxGetApp().app_config);
check_install_indices();
@@ -209,6 +224,9 @@ void PresetUpdater::priv::sync_version() const
.on_complete([&](std::string body, unsigned /* http_status */) {
boost::trim(body);
BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body;
+
+ // FIXME: race condition
+
// wxCommandEvent* evt = new wxCommandEvent(version_online_event);
// evt->SetString(body);
// GUI::get_app()->QueueEvent(evt);
@@ -260,7 +278,7 @@ void PresetUpdater::priv::sync_config(const std::set<VendorProfile> vendors)
continue;
}
if (new_index.version() < index.version()) {
- BOOST_LOG_TRIVIAL(error) << boost::format("The downloaded index %1% for vendor %2% is older than the active one. Ignoring the downloaded index.") % idx_path_temp % vendor.name;
+ BOOST_LOG_TRIVIAL(warning) << boost::format("The downloaded index %1% for vendor %2% is older than the active one. Ignoring the downloaded index.") % idx_path_temp % vendor.name;
continue;
}
Slic3r::rename_file(idx_path_temp, idx_path);
@@ -275,6 +293,7 @@ void PresetUpdater::priv::sync_config(const std::set<VendorProfile> vendors)
BOOST_LOG_TRIVIAL(error) << boost::format("No recommended version for vendor: %1%, invalid index?") % vendor.name;
continue;
}
+
const auto recommended = recommended_it->config_version;
BOOST_LOG_TRIVIAL(debug) << boost::format("Got index for vendor: %1%: current version: %2%, recommended version: %3%")
@@ -341,7 +360,8 @@ Updates PresetUpdater::priv::get_config_updates() const
if (ver_current == idx.end()) {
auto message = (boost::format("Preset bundle `%1%` version not found in index: %2%") % idx.vendor() % vp.config_version.to_string()).str();
BOOST_LOG_TRIVIAL(error) << message;
- throw std::runtime_error(message);
+ GUI::show_error(nullptr, GUI::from_u8(message));
+ continue;
}
// Getting a recommended version from the latest index, wich may have been downloaded
@@ -528,18 +548,14 @@ void PresetUpdater::slic3r_update_notify()
}
auto* app_config = GUI::wxGetApp().app_config;
- const auto ver_slic3r = Semver::parse(SLIC3R_VERSION);
const auto ver_online_str = app_config->get("version_online");
const auto ver_online = Semver::parse(ver_online_str);
const auto ver_online_seen = Semver::parse(app_config->get("version_online_seen"));
- if (! ver_slic3r) {
- throw std::runtime_error("Could not parse Slic3r version string: " SLIC3R_VERSION);
- }
if (ver_online) {
// Only display the notification if the version available online is newer AND if we haven't seen it before
- if (*ver_online > *ver_slic3r && (! ver_online_seen || *ver_online_seen < *ver_online)) {
- GUI::MsgUpdateSlic3r notification(*ver_slic3r, *ver_online);
+ if (*ver_online > p->ver_slic3r && (! ver_online_seen || *ver_online_seen < *ver_online)) {
+ GUI::MsgUpdateSlic3r notification(p->ver_slic3r, *ver_online);
notification.ShowModal();
if (notification.disable_version_check()) {
app_config->set("version_check", "0");