diff --git a/xs/src/libslic3r/PrintExport.hpp b/xs/src/libslic3r/PrintExport.hpp index 9e8e19a15..770dd02bd 100644 --- a/xs/src/libslic3r/PrintExport.hpp +++ b/xs/src/libslic3r/PrintExport.hpp @@ -175,7 +175,7 @@ public: wxFFileOutputStream zipfile(path); - std::string project = filepath.GetName(); + std::string project = filepath.GetName().ToStdString(); if(!zipfile.IsOk()) { BOOST_LOG_TRIVIAL(error) << "Can't create zip file for layers! " diff --git a/xs/src/slic3r/AppController.cpp b/xs/src/slic3r/AppController.cpp index 07ec8e39c..267a39d26 100644 --- a/xs/src/slic3r/AppController.cpp +++ b/xs/src/slic3r/AppController.cpp @@ -318,7 +318,9 @@ void PrintController::slice_to_png() report_issue(IssueType::WARN, ss.str(), "Warning"); } - std::async(std::launch::async, [this, exd]() { + std::async(supports_asynch()? std::launch::async : std::launch::deferred, + [this, exd]() + { progress_indicator(100, "Slicing to zipped png files..."); progress_indicator()->procedure_count(3); diff --git a/xs/src/slic3r/AppController.hpp b/xs/src/slic3r/AppController.hpp index 85e1f2e4d..832c61057 100644 --- a/xs/src/slic3r/AppController.hpp +++ b/xs/src/slic3r/AppController.hpp @@ -131,6 +131,22 @@ public: */ bool is_main_thread() const; + /** + * @brief The frontend supports asynch execution. + * + * A Graphic UI will support this, a CLI may not. This can be used in + * subclass methods to decide whether to start threads for block free UI. + * + * Note that even a progress indicator's update called regularly can solve + * the blocking UI problem in some cases even when an event loop is present. + * This is how wxWidgets gauge work but creating a separate thread will make + * the UI even more fluent. + * + * @return true if a job or method can be executed asynchronously, false + * otherwise. + */ + bool supports_asynch() const; + protected: /** diff --git a/xs/src/slic3r/AppControllerWx.cpp b/xs/src/slic3r/AppControllerWx.cpp index 04acaff42..76f415508 100644 --- a/xs/src/slic3r/AppControllerWx.cpp +++ b/xs/src/slic3r/AppControllerWx.cpp @@ -1,6 +1,7 @@ #include "AppController.hpp" #include +#include #include #include @@ -20,6 +21,11 @@ namespace Slic3r { +bool AppControllerBoilerplate::supports_asynch() const +{ + return true; +} + AppControllerBoilerplate::PathList AppControllerBoilerplate::query_destination_paths( const std::string &title,