From 1e6900afa22f7a650a1a6801017b597cb1656407 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 18 Dec 2018 15:55:45 +0100 Subject: [PATCH 1/6] Logging of memory usage for the GCodeAnalyzer and GCodePreviewData. --- src/libslic3r/GCode.cpp | 7 +++-- src/libslic3r/GCode/Analyzer.cpp | 11 ++++++++ src/libslic3r/GCode/Analyzer.hpp | 3 +++ src/libslic3r/GCode/PreviewData.cpp | 38 ++++++++++++++++++++++++++++ src/libslic3r/GCode/PreviewData.hpp | 12 +++++++++ src/libslic3r/GCodeTimeEstimator.cpp | 10 ++------ src/libslic3r/Utils.hpp | 7 ++++- 7 files changed, 77 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ef143a3e8e..e738662cba 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1644,8 +1644,11 @@ void GCode::process_layer( // printf("G-code after filter:\n%s\n", out.c_str()); _write(file, gcode); - BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z << ", time estimator memory: " + - format_memsize_MB(m_normal_time_estimator.memory_used() + m_silent_time_estimator_enabled ? m_silent_time_estimator.memory_used() : 0); + BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z << + ", time estimator memory: " << + format_memsize_MB(m_normal_time_estimator.memory_used() + m_silent_time_estimator_enabled ? m_silent_time_estimator.memory_used() : 0) << + ", analyzer memory: " << + format_memsize_MB(m_analyzer.memory_used()); } void GCode::apply_print_config(const PrintConfig &print_config) diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp index c56f02753a..8212b1703d 100644 --- a/src/libslic3r/GCode/Analyzer.cpp +++ b/src/libslic3r/GCode/Analyzer.cpp @@ -4,6 +4,7 @@ #include "../libslic3r.h" #include "../PrintConfig.hpp" +#include "../Utils.hpp" #include "Print.hpp" #include "Analyzer.hpp" @@ -852,6 +853,16 @@ void GCodeAnalyzer::_calc_gcode_preview_unretractions(GCodePreviewData& preview_ } } +// Return an estimate of the memory consumed by the time estimator. +size_t GCodeAnalyzer::memory_used() const +{ + size_t out = sizeof(*this); + for (const std::pair &kvp : m_moves_map) + out += sizeof(kvp) + SLIC3R_STDVEC_MEMSIZE(kvp.second, GCodeMove); + out += m_process_output.size(); + return out; +} + GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2) { return GCodePreviewData::Color(clamp(0.0f, 1.0f, c1.rgba[0] + c2.rgba[0]), diff --git a/src/libslic3r/GCode/Analyzer.hpp b/src/libslic3r/GCode/Analyzer.hpp index f50138b56d..389c11cec4 100644 --- a/src/libslic3r/GCode/Analyzer.hpp +++ b/src/libslic3r/GCode/Analyzer.hpp @@ -120,6 +120,9 @@ public: // Calculates all data needed for gcode visualization void calc_gcode_preview_data(GCodePreviewData& preview_data); + // Return an estimate of the memory consumed by the time estimator. + size_t memory_used() const; + static bool is_valid_extrusion_role(ExtrusionRole role); private: diff --git a/src/libslic3r/GCode/PreviewData.cpp b/src/libslic3r/GCode/PreviewData.cpp index 3f2df95324..d4aa9bc021 100644 --- a/src/libslic3r/GCode/PreviewData.cpp +++ b/src/libslic3r/GCode/PreviewData.cpp @@ -2,6 +2,7 @@ #include "PreviewData.hpp" #include #include +#include "Utils.hpp" #include @@ -205,6 +206,18 @@ bool GCodePreviewData::Extrusion::is_role_flag_set(unsigned int flags, Extrusion return GCodeAnalyzer::is_valid_extrusion_role(role) && (flags & (1 << (role - erPerimeter))) != 0; } +size_t GCodePreviewData::Extrusion::memory_used() const +{ + size_t out = sizeof(*this); + out += SLIC3R_STDVEC_MEMSIZE(this->layers, Layer); + for (const Layer &layer : this->layers) { + out += SLIC3R_STDVEC_MEMSIZE(layer.paths, ExtrusionPath); + for (const ExtrusionPath &path : layer.paths) + out += SLIC3R_STDVEC_MEMSIZE(path.polyline.points, Point); + } + return out; +} + const float GCodePreviewData::Travel::Default_Width = 0.075f; const float GCodePreviewData::Travel::Default_Height = 0.075f; const GCodePreviewData::Color GCodePreviewData::Travel::Default_Type_Colors[Num_Types] = @@ -224,6 +237,15 @@ void GCodePreviewData::Travel::set_default() is_visible = false; } +size_t GCodePreviewData::Travel::memory_used() const +{ + size_t out = sizeof(*this); + out += SLIC3R_STDVEC_MEMSIZE(this->polylines, Polyline); + for (const Polyline &polyline : this->polylines) + out += SLIC3R_STDVEC_MEMSIZE(polyline.polyline.points, Vec3crd); + return out; +} + const GCodePreviewData::Color GCodePreviewData::Retraction::Default_Color = GCodePreviewData::Color(1.0f, 1.0f, 1.0f, 1.0f); GCodePreviewData::Retraction::Position::Position(const Vec3crd& position, float width, float height) @@ -239,6 +261,11 @@ void GCodePreviewData::Retraction::set_default() is_visible = false; } +size_t GCodePreviewData::Retraction::memory_used() const +{ + return sizeof(*this) + SLIC3R_STDVEC_MEMSIZE(this->positions, Position); +} + void GCodePreviewData::Shell::set_default() { is_visible = false; @@ -483,4 +510,15 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std:: return items; } +// Return an estimate of the memory consumed by the time estimator. +size_t GCodePreviewData::memory_used() const +{ + return + this->extrusion.memory_used() + + this->travel.memory_used() + + this->retraction.memory_used() + + this->unretraction.memory_used() + + sizeof(shell) + sizeof(ranges); +} + } // namespace Slic3r diff --git a/src/libslic3r/GCode/PreviewData.hpp b/src/libslic3r/GCode/PreviewData.hpp index 9f882788d0..8ed5e91c73 100644 --- a/src/libslic3r/GCode/PreviewData.hpp +++ b/src/libslic3r/GCode/PreviewData.hpp @@ -99,6 +99,9 @@ public: void set_default(); bool is_role_flag_set(ExtrusionRole role) const; + // Return an estimate of the memory consumed by the time estimator. + size_t memory_used() const; + static bool is_role_flag_set(unsigned int flags, ExtrusionRole role); }; @@ -144,6 +147,9 @@ public: size_t color_print_idx; void set_default(); + + // Return an estimate of the memory consumed by the time estimator. + size_t memory_used() const; }; struct Retraction @@ -166,6 +172,9 @@ public: bool is_visible; void set_default(); + + // Return an estimate of the memory consumed by the time estimator. + size_t memory_used() const; }; struct Shell @@ -199,6 +208,9 @@ public: std::string get_legend_title() const; LegendItemsList get_legend_items(const std::vector& tool_colors, const std::vector>& cp_values) const; + + // Return an estimate of the memory consumed by the time estimator. + size_t memory_used() const; }; GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2); diff --git a/src/libslic3r/GCodeTimeEstimator.cpp b/src/libslic3r/GCodeTimeEstimator.cpp index 0ab49a3451..81119c5135 100644 --- a/src/libslic3r/GCodeTimeEstimator.cpp +++ b/src/libslic3r/GCodeTimeEstimator.cpp @@ -672,14 +672,8 @@ namespace Slic3r { size_t GCodeTimeEstimator::memory_used() const { size_t out = sizeof(*this); -#if WIN32 - #define STDVEC_MEMSIZE(NAME, TYPE) NAME.capacity() * ((sizeof(TYPE) + __alignof(TYPE) - 1) / __alignof(TYPE)) * __alignof(TYPE) -#else - #define STDVEC_MEMSIZE(NAME, TYPE) NAME.capacity() * ((sizeof(TYPE) + alignof(TYPE) - 1) / alignof(TYPE)) * alignof(TYPE) -#endif - out += STDVEC_MEMSIZE(this->_blocks, Block); - out += STDVEC_MEMSIZE(this->_g1_line_ids, G1LineIdToBlockId); -#undef STDVEC_MEMSIZE + out += SLIC3R_STDVEC_MEMSIZE(this->_blocks, Block); + out += SLIC3R_STDVEC_MEMSIZE(this->_g1_line_ids, G1LineIdToBlockId); return out; } diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index f4f05ae663..047e03bf23 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -187,7 +187,12 @@ public: void reset() { closure = Closure(); } }; - } // namespace Slic3r +#if WIN32 + #define SLIC3R_STDVEC_MEMSIZE(NAME, TYPE) NAME.capacity() * ((sizeof(TYPE) + __alignof(TYPE) - 1) / __alignof(TYPE)) * __alignof(TYPE) +#else + #define SLIC3R_STDVEC_MEMSIZE(NAME, TYPE) NAME.capacity() * ((sizeof(TYPE) + alignof(TYPE) - 1) / alignof(TYPE)) * alignof(TYPE) +#endif + #endif // slic3r_Utils_hpp_ From e2d7fd941f6d53ba9dc40c8643f54f7529edc6eb Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 18 Dec 2018 16:32:11 +0100 Subject: [PATCH 2/6] Fixed OSX/Linux builds --- src/libslic3r/utils.cpp | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 8081828c77..18e27f34b8 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -366,6 +366,32 @@ std::string xml_escape(std::string text) return text; } +std::string format_memsize_MB(size_t n) +{ + std::string out; + size_t n2 = 0; + size_t scale = 1; + // Round to MB + n += 500000; + n /= 1000000; + while (n >= 1000) { + n2 = n2 + scale * (n % 1000); + n /= 1000; + scale *= 1000; + } + char buf[8]; + sprintf(buf, "%d", n); + out = buf; + while (scale != 1) { + scale /= 1000; + n = n2 / scale; + n2 = n2 % scale; + sprintf(buf, ",%03d", n); + out += buf; + } + return out + "MB"; +} + #ifdef WIN32 #ifndef PROCESS_MEMORY_COUNTERS_EX @@ -385,32 +411,6 @@ std::string xml_escape(std::string text) } PROCESS_MEMORY_COUNTERS_EX, *PPROCESS_MEMORY_COUNTERS_EX; #endif /* PROCESS_MEMORY_COUNTERS_EX */ -std::string format_memsize_MB(size_t n) -{ - std::string out; - size_t n2 = 0; - size_t scale = 1; - // Round to MB - n += 500000; - n /= 1000000; - while (n >= 1000) { - n2 = n2 + scale * (n % 1000); - n /= 1000; - scale *= 1000; - } - char buf[8]; - sprintf(buf, "%d", n); - out = buf; - while (scale != 1) { - scale /= 1000; - n = n2 / scale; - n2 = n2 % scale; - sprintf(buf, ",%03d", n); - out += buf; - } - return out + "MB"; -} - std::string log_memory_info() { std::string out; From 8bc04e640aae1b45de9f987b826e2e04aa0c601f Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 18 Dec 2018 17:34:21 +0100 Subject: [PATCH 3/6] The G-code export was reshuffled a bit to reduce peak memory consumption. Namely, the time estimate memory is released before the G-code preview data is created from the G-code analyser data. --- src/libslic3r/GCode.cpp | 40 ++++++++++++++++++++++------------------ src/libslic3r/GCode.hpp | 2 +- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index e738662cba..b13c387425 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -435,9 +435,11 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_ if (file == nullptr) throw std::runtime_error(std::string("G-code export to ") + path + " failed.\nCannot open the file for writing.\n"); + m_enable_analyzer = preview_data != nullptr; + try { m_placeholder_parser_failed_templates.clear(); - this->_do_export(*print, file, preview_data); + this->_do_export(*print, file); fflush(file); if (ferror(file)) { fclose(file); @@ -453,15 +455,6 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_ } fclose(file); - if (print->config().remaining_times.value) { - BOOST_LOG_TRIVIAL(debug) << "Processing remaining times for normal mode"; - m_normal_time_estimator.post_process_remaining_times(path_tmp, 60.0f); - if (m_silent_time_estimator_enabled) { - BOOST_LOG_TRIVIAL(debug) << "Processing remaining times for silent mode"; - m_silent_time_estimator.post_process_remaining_times(path_tmp, 60.0f); - } - } - if (! m_placeholder_parser_failed_templates.empty()) { // G-code export proceeded, but some of the PlaceholderParser substitutions failed. std::string msg = std::string("G-code export to ") + path + " failed due to invalid custom G-code sections:\n\n"; @@ -475,6 +468,24 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_ throw std::runtime_error(msg); } + if (print->config().remaining_times.value) { + BOOST_LOG_TRIVIAL(debug) << "Processing remaining times for normal mode"; + m_normal_time_estimator.post_process_remaining_times(path_tmp, 60.0f); + m_normal_time_estimator.reset(); + if (m_silent_time_estimator_enabled) { + BOOST_LOG_TRIVIAL(debug) << "Processing remaining times for silent mode"; + m_silent_time_estimator.post_process_remaining_times(path_tmp, 60.0f); + m_silent_time_estimator.reset(); + } + } + + // starts analyzer calculations + if (m_enable_analyzer) { + BOOST_LOG_TRIVIAL(debug) << "Preparing G-code preview data"; + m_analyzer.calc_gcode_preview_data(*preview_data); + m_analyzer.reset(); + } + if (rename_file(path_tmp, path) != 0) throw std::runtime_error( std::string("Failed to rename the output G-code file from ") + path_tmp + " to " + path + '\n' + @@ -488,7 +499,7 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_ PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str()); } -void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) +void GCode::_do_export(Print &print, FILE *file) { PROFILE_FUNC(); @@ -558,7 +569,6 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) // resets analyzer m_analyzer.reset(); - m_enable_analyzer = preview_data != nullptr; // resets analyzer's tracking data m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm; @@ -1034,12 +1044,6 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) _write(file, full_config); } print.throw_if_canceled(); - - // starts analyzer calculations - if (preview_data != nullptr) { - BOOST_LOG_TRIVIAL(debug) << "Preparing G-code preview data"; - m_analyzer.calc_gcode_preview_data(*preview_data); - } } std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override) diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index bf65311db4..32a7057512 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -180,7 +180,7 @@ public: static void append_full_config(const Print& print, std::string& str); protected: - void _do_export(Print &print, FILE *file, GCodePreviewData *preview_data); + void _do_export(Print &print, FILE *file); // Object and support extrusions of the same PrintObject at the same print_z. struct LayerToPrint From bb5caf2e08ca3be318501ff0580242e84d1e4355 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 18 Dec 2018 18:41:20 +0100 Subject: [PATCH 4/6] Fixed scaling of the object, if it was loaded too big. Here the large object was not scaled uniformly, and the Z height of the bed was set incorrectly to one. --- src/slic3r/GUI/Plater.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index ab7141e919..a261e7e05a 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1526,9 +1526,8 @@ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &mode if (max_ratio > 10000) { // the size of the object is too big -> this could lead to overflow when moving to clipper coordinates, // so scale down the mesh - // const Vec3d inverse = ratio.cwiseInverse(); - // object->scale(inverse); - object->scale(ratio.cwiseInverse()); + double inv = 1. / max_ratio; + object->scale(Vec3d(inv, inv, inv)); scaled_down = true; } else if (max_ratio > 5) { const Vec3d inverse = ratio.cwiseInverse(); From ec9caae6227d8a151bd673d1e1214f197c803d1a Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 18 Dec 2018 18:40:35 +0100 Subject: [PATCH 5/6] Http & ErrorDialog: Improve error reporting --- src/libslic3r/Utils.hpp | 1 + src/libslic3r/utils.cpp | 12 ++++++++++++ src/slic3r/GUI/MsgDialog.cpp | 22 ++++++++++++++++++++-- src/slic3r/GUI/MsgDialog.hpp | 6 +++++- src/slic3r/Utils/Http.cpp | 25 ++++++++++++++----------- src/slic3r/Utils/PrintHost.cpp | 11 ++++++++++- 6 files changed, 62 insertions(+), 15 deletions(-) diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 047e03bf23..cfae9edd1a 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -11,6 +11,7 @@ namespace Slic3r { extern void set_logging_level(unsigned int level); +extern unsigned get_logging_level(); extern void trace(unsigned int level, const char *message); // Format memory allocated, separate thousands by comma. extern std::string format_memsize_MB(size_t n); diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 18e27f34b8..f48abfd89e 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -59,6 +59,18 @@ void set_logging_level(unsigned int level) ); } +unsigned get_logging_level() +{ + switch (logSeverity) { + case boost::log::trivial::fatal : return 0; + case boost::log::trivial::error : return 1; + case boost::log::trivial::warning : return 2; + case boost::log::trivial::info : return 3; + case boost::log::trivial::debug : return 4; + default: return 1; + } +} + // Force set_logging_level(<=error) after loading of the DLL. // Switch boost::filesystem to utf8. static struct RunOnInit { diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index ae7b404848..d6b8b438e9 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "libslic3r/libslic3r.h" #include "libslic3r/Utils.hpp" @@ -61,8 +62,11 @@ MsgDialog::~MsgDialog() {} // ErrorDialog -ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) : - MsgDialog(parent, _(L("Slic3r error")), _(L("Slic3r has encountered an error")), wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png")), wxBITMAP_TYPE_PNG)) +ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) + : MsgDialog(parent, _(L("Slic3r error")), _(L("Slic3r has encountered an error")), + wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png")), wxBITMAP_TYPE_PNG), + wxID_NONE) + , msg(msg) { auto *panel = new wxScrolledWindow(this); auto *p_sizer = new wxBoxSizer(wxVERTICAL); @@ -77,6 +81,20 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) : content_sizer->Add(panel, 1, wxEXPAND); + auto *btn_copy = new wxButton(this, wxID_ANY, _(L("Copy to clipboard"))); + btn_copy->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { + if (wxTheClipboard->Open()) { + wxTheClipboard->SetData(new wxTextDataObject(this->msg)); // Note: the clipboard takes ownership of the pointer + wxTheClipboard->Close(); + } + }); + + auto *btn_ok = new wxButton(this, wxID_OK); + btn_ok->SetFocus(); + + btn_sizer->Add(btn_copy, 0, wxRIGHT, HORIZ_SPACING); + btn_sizer->Add(btn_ok); + SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT)); Fit(); } diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index ca349eb5c8..6064d2a9f5 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -50,14 +50,18 @@ protected: // Generic error dialog, used for displaying exceptions -struct ErrorDialog : MsgDialog +class ErrorDialog : public MsgDialog { +public: ErrorDialog(wxWindow *parent, const wxString &msg); ErrorDialog(ErrorDialog &&) = delete; ErrorDialog(const ErrorDialog &) = delete; ErrorDialog &operator=(ErrorDialog &&) = delete; ErrorDialog &operator=(const ErrorDialog &) = delete; virtual ~ErrorDialog(); + +private: + wxString msg; }; diff --git a/src/slic3r/Utils/Http.cpp b/src/slic3r/Utils/Http.cpp index 67c24f3f4a..6e6c9ed44b 100644 --- a/src/slic3r/Utils/Http.cpp +++ b/src/slic3r/Utils/Http.cpp @@ -11,6 +11,7 @@ #include #include "libslic3r/libslic3r.h" +#include "libslic3r/Utils.hpp" namespace fs = boost::filesystem; @@ -44,6 +45,7 @@ struct Http::priv // Using a deque here because unlike vector it doesn't ivalidate pointers on insertion std::deque form_files; std::string postfields; + std::string error_buffer; // Used for CURLOPT_ERRORBUFFER size_t limit; bool cancel; @@ -69,13 +71,14 @@ struct Http::priv void http_perform(); }; -Http::priv::priv(const std::string &url) : - curl(::curl_easy_init()), - form(nullptr), - form_end(nullptr), - headerlist(nullptr), - limit(0), - cancel(false) +Http::priv::priv(const std::string &url) + : curl(::curl_easy_init()) + , form(nullptr) + , form_end(nullptr) + , headerlist(nullptr) + , error_buffer(CURL_ERROR_SIZE + 1, '\0') + , limit(0) + , cancel(false) { if (curl == nullptr) { throw std::runtime_error(std::string("Could not construct Curl object")); @@ -83,6 +86,7 @@ Http::priv::priv(const std::string &url) : ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); // curl makes a copy internally ::curl_easy_setopt(curl, CURLOPT_USERAGENT, SLIC3R_FORK_NAME "/" SLIC3R_VERSION); + ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer.front()); } Http::priv::~priv() @@ -199,9 +203,10 @@ void Http::priv::set_post_body(const fs::path &path) std::string Http::priv::curl_error(CURLcode curlcode) { - return (boost::format("%1% (%2%)") + return (boost::format("%1% (%2%): %3%") % ::curl_easy_strerror(curlcode) % curlcode + % error_buffer ).str(); } @@ -227,9 +232,7 @@ void Http::priv::http_perform() ::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, static_cast(this)); #endif -#ifndef NDEBUG - ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); -#endif + ::curl_easy_setopt(curl, CURLOPT_VERBOSE, get_logging_level() >= 4); if (headerlist != nullptr) { ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); diff --git a/src/slic3r/Utils/PrintHost.cpp b/src/slic3r/Utils/PrintHost.cpp index 863da5d433..cdd0c107ef 100644 --- a/src/slic3r/Utils/PrintHost.cpp +++ b/src/slic3r/Utils/PrintHost.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -144,6 +145,10 @@ void PrintHostJobQueue::priv::perform_job(PrintHostJob the_job) { if (bg_exit || the_job.empty()) { return; } + BOOST_LOG_TRIVIAL(debug) << boost::format("PrintHostJobQueue/bg_thread: Got job: `%1%` -> `%1%`") + % the_job.upload_data.upload_path + % the_job.printhost->get_host(); + const fs::path gcode_path = the_job.upload_data.source_path; the_job.printhost->upload(std::move(the_job.upload_data), @@ -154,7 +159,11 @@ void PrintHostJobQueue::priv::perform_job(PrintHostJob the_job) auto evt = new PrintHostQueueDialog::Event(GUI::EVT_PRINTHOST_PROGRESS, queue_dialog->GetId(), job_id, 100); wxQueueEvent(queue_dialog, evt); - fs::remove(gcode_path); // XXX: error handling + boost::system::error_code ec; + fs::remove(gcode_path, ec); + if (ec) { + BOOST_LOG_TRIVIAL(error) << boost::format("PrintHostJobQueue: Error removing file `%1%`: %2%") % gcode_path % ec; + } } void PrintHostJobQueue::enqueue(PrintHostJob job) From 76c922bf9ab80a4d40ca10d1cd54443a4dcecf69 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 18 Dec 2018 19:12:59 +0100 Subject: [PATCH 6/6] Fixed a crash when trying to delete a wipe tower with the delete key. --- src/slic3r/GUI/GUI_ObjectList.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index e7b84e2890..5e20ceaab5 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -982,6 +982,10 @@ void ObjectList::del_instances_from_object(const int obj_idx) bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, const int type) { + if (obj_idx == 1000) + // Cannot delete a wipe tower. + return false; + if (type == itVolume) { const auto volume = (*m_objects)[obj_idx]->volumes[idx];