Merge branch 'master' of https://github.com/prusa3d/Slic3r into time_estimate

This commit is contained in:
Enrico Turri 2018-06-04 09:29:16 +02:00
commit 8dc3a73571
6 changed files with 67 additions and 2008 deletions

View file

@ -252,7 +252,7 @@ static void usage(void)
// setvbuf(stderr, (char*)NULL, _IOLBF, 0);
// }
static bool update_progress_no_tty (int percent, double etime, char *hdr)
static void update_progress_no_tty (int percent, double etime, char *hdr)
{
static int done = 0;
static int last = 0;

View file

@ -3,7 +3,7 @@
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <boost/format.hpp>
#include <boost/log/trivial.hpp>
#include <wx/settings.h>
@ -615,8 +615,14 @@ void ConfigWizard::priv::load_vendors()
// Load vendors from the "vendors" directory in datadir
for (fs::directory_iterator it(vendor_dir); it != fs::directory_iterator(); ++it) {
if (it->path().extension() == ".ini") {
auto vp = VendorProfile::from_ini(it->path());
vendors[vp.id] = std::move(vp);
try {
auto vp = VendorProfile::from_ini(it->path());
vendors[vp.id] = std::move(vp);
}
catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << boost::format("Error loading vendor bundle %1%: %2%") % it->path() % e.what();
}
}
}
@ -625,9 +631,14 @@ void ConfigWizard::priv::load_vendors()
if (it->path().extension() == ".ini") {
const auto id = it->path().stem().string();
if (vendors.find(id) == vendors.end()) {
auto vp = VendorProfile::from_ini(it->path());
vendors_rsrc[vp.id] = it->path().filename().string();
vendors[vp.id] = std::move(vp);
try {
auto vp = VendorProfile::from_ini(it->path());
vendors_rsrc[vp.id] = it->path().filename().string();
vendors[vp.id] = std::move(vp);
}
catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << boost::format("Error loading vendor bundle %1%: %2%") % it->path() % e.what();
}
}
}
}

View file

@ -394,7 +394,7 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l
void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change)
{
add_config_menu(menu, event_language_change, event_language_change);
add_config_menu(menu, event_preferences_changed, event_language_change);
}
// This is called when closing the application, when loading a config file or when starting the config wizard
@ -443,8 +443,13 @@ void config_wizard(int reason)
if (! check_unsaved_changes())
return;
ConfigWizard wizard(nullptr, static_cast<ConfigWizard::RunReason>(reason));
wizard.run(g_PresetBundle, g_PresetUpdater);
try {
ConfigWizard wizard(nullptr, static_cast<ConfigWizard::RunReason>(reason));
wizard.run(g_PresetBundle, g_PresetUpdater);
}
catch (const std::exception &e) {
show_error(nullptr, e.what());
}
// Load the currently selected preset into the GUI, update the preset selection box.
for (Tab *tab : g_tabs_list)
@ -929,34 +934,51 @@ void about()
}
void desktop_open_datadir_folder()
{
{
// Execute command to open a file explorer, platform dependent.
std::string cmd =
// FIXME: The const_casts aren't needed in wxWidgets 3.1, remove them when we upgrade.
const auto path = data_dir();
#ifdef _WIN32
"explorer "
const auto widepath = wxString::FromUTF8(path.data());
const wchar_t *argv[] = { L"explorer", widepath.GetData(), nullptr };
::wxExecute(const_cast<wchar_t**>(argv), wxEXEC_ASYNC, nullptr);
#elif __APPLE__
"open "
const char *argv[] = { "open", path.data(), nullptr };
::wxExecute(const_cast<char**>(argv), wxEXEC_ASYNC, nullptr);
#else
"xdg-open "
const char *argv[] = { "xdg-open", path.data(), nullptr };
// Check if we're running in an AppImage container, if so, we need to remove AppImage's env vars,
// because they may mess up the environment expected by the file manager.
// Mostly this is about LD_LIBRARY_PATH, but we remove a few more too for good measure.
if (wxGetEnv("APPIMAGE", nullptr)) {
// We're running from AppImage
wxEnvVariableHashMap env_vars;
wxGetEnvMap(&env_vars);
env_vars.erase("APPIMAGE");
env_vars.erase("APPDIR");
env_vars.erase("LD_LIBRARY_PATH");
env_vars.erase("LD_PRELOAD");
env_vars.erase("UNION_PRELOAD");
wxExecuteEnv exec_env;
exec_env.env = std::move(env_vars);
wxString owd;
if (wxGetEnv("OWD", &owd)) {
// This is the original work directory from which the AppImage image was run,
// set it as CWD for the child process:
exec_env.cwd = std::move(owd);
}
::wxExecute(const_cast<char**>(argv), wxEXEC_ASYNC, nullptr, &exec_env);
} else {
// Looks like we're NOT running from AppImage, we'll make no changes to the environment.
::wxExecute(const_cast<char**>(argv), wxEXEC_ASYNC, nullptr, nullptr);
}
#endif
;
// Escape the path, platform dependent.
std::string path = data_dir();
#ifdef _WIN32
// Enclose the path into double quotes on Windows. A quote character is forbidden in file names,
// therefore it does not need to be escaped.
cmd += '"';
cmd += path;
cmd += '"';
#else
// Enclose the path into single quotes on Unix / OSX. All single quote characters need to be escaped
// inside a file name.
cmd += '\'';
boost::replace_all(path, "'", "\\'");
cmd += path;
cmd += '\'';
#endif
::wxExecute(wxString::FromUTF8(cmd.c_str()), wxEXEC_ASYNC, nullptr);
}
} }

View file

@ -66,11 +66,7 @@ bool check_unsaved_changes()
bool config_wizard_startup(int app_config_exists)
%code%{
try {
RETVAL=Slic3r::GUI::config_wizard_startup(app_config_exists != 0);
} catch (std::exception& e) {
croak("%s\n", e.what());
}
RETVAL=Slic3r::GUI::config_wizard_startup(app_config_exists != 0);
%};
void open_preferences_dialog(int preferences_event)