This commit is contained in:
Enrico Turri 2018-12-19 08:24:52 +01:00
commit 42249d6649
15 changed files with 194 additions and 74 deletions

View file

@ -435,9 +435,11 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_
if (file == nullptr) if (file == nullptr)
throw std::runtime_error(std::string("G-code export to ") + path + " failed.\nCannot open the file for writing.\n"); 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 { try {
m_placeholder_parser_failed_templates.clear(); m_placeholder_parser_failed_templates.clear();
this->_do_export(*print, file, preview_data); this->_do_export(*print, file);
fflush(file); fflush(file);
if (ferror(file)) { if (ferror(file)) {
fclose(file); fclose(file);
@ -453,15 +455,6 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_
} }
fclose(file); 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()) { if (! m_placeholder_parser_failed_templates.empty()) {
// G-code export proceeded, but some of the PlaceholderParser substitutions failed. // 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"; 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); 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) if (rename_file(path_tmp, path) != 0)
throw std::runtime_error( throw std::runtime_error(
std::string("Failed to rename the output G-code file from ") + path_tmp + " to " + path + '\n' + 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()); 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(); PROFILE_FUNC();
@ -558,7 +569,6 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data)
// resets analyzer // resets analyzer
m_analyzer.reset(); m_analyzer.reset();
m_enable_analyzer = preview_data != nullptr;
// resets analyzer's tracking data // resets analyzer's tracking data
m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm; 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); _write(file, full_config);
} }
print.throw_if_canceled(); 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) std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override)
@ -1644,8 +1648,11 @@ void GCode::process_layer(
// printf("G-code after filter:\n%s\n", out.c_str()); // printf("G-code after filter:\n%s\n", out.c_str());
_write(file, gcode); _write(file, gcode);
BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z << ", time estimator memory: " + BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z <<
format_memsize_MB(m_normal_time_estimator.memory_used() + m_silent_time_estimator_enabled ? m_silent_time_estimator.memory_used() : 0); ", 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) void GCode::apply_print_config(const PrintConfig &print_config)

View file

@ -180,7 +180,7 @@ public:
static void append_full_config(const Print& print, std::string& str); static void append_full_config(const Print& print, std::string& str);
protected: 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. // Object and support extrusions of the same PrintObject at the same print_z.
struct LayerToPrint struct LayerToPrint

View file

@ -4,6 +4,7 @@
#include "../libslic3r.h" #include "../libslic3r.h"
#include "../PrintConfig.hpp" #include "../PrintConfig.hpp"
#include "../Utils.hpp"
#include "Print.hpp" #include "Print.hpp"
#include "Analyzer.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<GCodeMove::EType, GCodeMovesList> &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) 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]), return GCodePreviewData::Color(clamp(0.0f, 1.0f, c1.rgba[0] + c2.rgba[0]),

View file

@ -120,6 +120,9 @@ public:
// Calculates all data needed for gcode visualization // Calculates all data needed for gcode visualization
void calc_gcode_preview_data(GCodePreviewData& preview_data); 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); static bool is_valid_extrusion_role(ExtrusionRole role);
private: private:

View file

@ -2,6 +2,7 @@
#include "PreviewData.hpp" #include "PreviewData.hpp"
#include <float.h> #include <float.h>
#include <I18N.hpp> #include <I18N.hpp>
#include "Utils.hpp"
#include <boost/format.hpp> #include <boost/format.hpp>
@ -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; 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_Width = 0.075f;
const float GCodePreviewData::Travel::Default_Height = 0.075f; const float GCodePreviewData::Travel::Default_Height = 0.075f;
const GCodePreviewData::Color GCodePreviewData::Travel::Default_Type_Colors[Num_Types] = const GCodePreviewData::Color GCodePreviewData::Travel::Default_Type_Colors[Num_Types] =
@ -224,6 +237,15 @@ void GCodePreviewData::Travel::set_default()
is_visible = false; 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); 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) GCodePreviewData::Retraction::Position::Position(const Vec3crd& position, float width, float height)
@ -239,6 +261,11 @@ void GCodePreviewData::Retraction::set_default()
is_visible = false; is_visible = false;
} }
size_t GCodePreviewData::Retraction::memory_used() const
{
return sizeof(*this) + SLIC3R_STDVEC_MEMSIZE(this->positions, Position);
}
void GCodePreviewData::Shell::set_default() void GCodePreviewData::Shell::set_default()
{ {
is_visible = false; is_visible = false;
@ -483,4 +510,15 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
return items; 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 } // namespace Slic3r

View file

@ -99,6 +99,9 @@ public:
void set_default(); void set_default();
bool is_role_flag_set(ExtrusionRole role) const; 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); static bool is_role_flag_set(unsigned int flags, ExtrusionRole role);
}; };
@ -144,6 +147,9 @@ public:
size_t color_print_idx; size_t color_print_idx;
void set_default(); void set_default();
// Return an estimate of the memory consumed by the time estimator.
size_t memory_used() const;
}; };
struct Retraction struct Retraction
@ -166,6 +172,9 @@ public:
bool is_visible; bool is_visible;
void set_default(); void set_default();
// Return an estimate of the memory consumed by the time estimator.
size_t memory_used() const;
}; };
struct Shell struct Shell
@ -199,6 +208,9 @@ public:
std::string get_legend_title() const; std::string get_legend_title() const;
LegendItemsList get_legend_items(const std::vector<float>& tool_colors, const std::vector</*double*/std::pair<double, double>>& cp_values) const; LegendItemsList get_legend_items(const std::vector<float>& tool_colors, const std::vector</*double*/std::pair<double, double>>& 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); GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2);

View file

@ -672,14 +672,8 @@ namespace Slic3r {
size_t GCodeTimeEstimator::memory_used() const size_t GCodeTimeEstimator::memory_used() const
{ {
size_t out = sizeof(*this); size_t out = sizeof(*this);
#if WIN32 out += SLIC3R_STDVEC_MEMSIZE(this->_blocks, Block);
#define STDVEC_MEMSIZE(NAME, TYPE) NAME.capacity() * ((sizeof(TYPE) + __alignof(TYPE) - 1) / __alignof(TYPE)) * __alignof(TYPE) out += SLIC3R_STDVEC_MEMSIZE(this->_g1_line_ids, G1LineIdToBlockId);
#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
return out; return out;
} }

View file

@ -11,6 +11,7 @@
namespace Slic3r { namespace Slic3r {
extern void set_logging_level(unsigned int level); extern void set_logging_level(unsigned int level);
extern unsigned get_logging_level();
extern void trace(unsigned int level, const char *message); extern void trace(unsigned int level, const char *message);
// Format memory allocated, separate thousands by comma. // Format memory allocated, separate thousands by comma.
extern std::string format_memsize_MB(size_t n); extern std::string format_memsize_MB(size_t n);
@ -187,7 +188,12 @@ public:
void reset() { closure = Closure(); } void reset() { closure = Closure(); }
}; };
} // namespace Slic3r } // 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_ #endif // slic3r_Utils_hpp_

View file

@ -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. // Force set_logging_level(<=error) after loading of the DLL.
// Switch boost::filesystem to utf8. // Switch boost::filesystem to utf8.
static struct RunOnInit { static struct RunOnInit {
@ -366,25 +378,6 @@ std::string xml_escape(std::string text)
return text; return text;
} }
#ifdef WIN32
#ifndef PROCESS_MEMORY_COUNTERS_EX
// MingW32 doesn't have this struct in psapi.h
typedef struct _PROCESS_MEMORY_COUNTERS_EX {
DWORD cb;
DWORD PageFaultCount;
SIZE_T PeakWorkingSetSize;
SIZE_T WorkingSetSize;
SIZE_T QuotaPeakPagedPoolUsage;
SIZE_T QuotaPagedPoolUsage;
SIZE_T QuotaPeakNonPagedPoolUsage;
SIZE_T QuotaNonPagedPoolUsage;
SIZE_T PagefileUsage;
SIZE_T PeakPagefileUsage;
SIZE_T PrivateUsage;
} PROCESS_MEMORY_COUNTERS_EX, *PPROCESS_MEMORY_COUNTERS_EX;
#endif /* PROCESS_MEMORY_COUNTERS_EX */
std::string format_memsize_MB(size_t n) std::string format_memsize_MB(size_t n)
{ {
std::string out; std::string out;
@ -411,6 +404,25 @@ std::string format_memsize_MB(size_t n)
return out + "MB"; return out + "MB";
} }
#ifdef WIN32
#ifndef PROCESS_MEMORY_COUNTERS_EX
// MingW32 doesn't have this struct in psapi.h
typedef struct _PROCESS_MEMORY_COUNTERS_EX {
DWORD cb;
DWORD PageFaultCount;
SIZE_T PeakWorkingSetSize;
SIZE_T WorkingSetSize;
SIZE_T QuotaPeakPagedPoolUsage;
SIZE_T QuotaPagedPoolUsage;
SIZE_T QuotaPeakNonPagedPoolUsage;
SIZE_T QuotaNonPagedPoolUsage;
SIZE_T PagefileUsage;
SIZE_T PeakPagefileUsage;
SIZE_T PrivateUsage;
} PROCESS_MEMORY_COUNTERS_EX, *PPROCESS_MEMORY_COUNTERS_EX;
#endif /* PROCESS_MEMORY_COUNTERS_EX */
std::string log_memory_info() std::string log_memory_info()
{ {
std::string out; std::string out;

View file

@ -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) 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) { if (type == itVolume) {
const auto volume = (*m_objects)[obj_idx]->volumes[idx]; const auto volume = (*m_objects)[obj_idx]->volumes[idx];

View file

@ -6,6 +6,7 @@
#include <wx/button.h> #include <wx/button.h>
#include <wx/statbmp.h> #include <wx/statbmp.h>
#include <wx/scrolwin.h> #include <wx/scrolwin.h>
#include <wx/clipbrd.h>
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
@ -61,8 +62,11 @@ MsgDialog::~MsgDialog() {}
// ErrorDialog // ErrorDialog
ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) : 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)) : 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 *panel = new wxScrolledWindow(this);
auto *p_sizer = new wxBoxSizer(wxVERTICAL); auto *p_sizer = new wxBoxSizer(wxVERTICAL);
@ -77,6 +81,20 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) :
content_sizer->Add(panel, 1, wxEXPAND); 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)); SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT));
Fit(); Fit();
} }

View file

@ -50,14 +50,18 @@ protected:
// Generic error dialog, used for displaying exceptions // Generic error dialog, used for displaying exceptions
struct ErrorDialog : MsgDialog class ErrorDialog : public MsgDialog
{ {
public:
ErrorDialog(wxWindow *parent, const wxString &msg); ErrorDialog(wxWindow *parent, const wxString &msg);
ErrorDialog(ErrorDialog &&) = delete; ErrorDialog(ErrorDialog &&) = delete;
ErrorDialog(const ErrorDialog &) = delete; ErrorDialog(const ErrorDialog &) = delete;
ErrorDialog &operator=(ErrorDialog &&) = delete; ErrorDialog &operator=(ErrorDialog &&) = delete;
ErrorDialog &operator=(const ErrorDialog &) = delete; ErrorDialog &operator=(const ErrorDialog &) = delete;
virtual ~ErrorDialog(); virtual ~ErrorDialog();
private:
wxString msg;
}; };

View file

@ -1526,9 +1526,8 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
if (max_ratio > 10000) { if (max_ratio > 10000) {
// the size of the object is too big -> this could lead to overflow when moving to clipper coordinates, // the size of the object is too big -> this could lead to overflow when moving to clipper coordinates,
// so scale down the mesh // so scale down the mesh
// const Vec3d inverse = ratio.cwiseInverse(); double inv = 1. / max_ratio;
// object->scale(inverse); object->scale(Vec3d(inv, inv, inv));
object->scale(ratio.cwiseInverse());
scaled_down = true; scaled_down = true;
} else if (max_ratio > 5) { } else if (max_ratio > 5) {
const Vec3d inverse = ratio.cwiseInverse(); const Vec3d inverse = ratio.cwiseInverse();

View file

@ -11,6 +11,7 @@
#include <curl/curl.h> #include <curl/curl.h>
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp"
namespace fs = boost::filesystem; 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 // Using a deque here because unlike vector it doesn't ivalidate pointers on insertion
std::deque<fs::ifstream> form_files; std::deque<fs::ifstream> form_files;
std::string postfields; std::string postfields;
std::string error_buffer; // Used for CURLOPT_ERRORBUFFER
size_t limit; size_t limit;
bool cancel; bool cancel;
@ -69,13 +71,14 @@ struct Http::priv
void http_perform(); void http_perform();
}; };
Http::priv::priv(const std::string &url) : Http::priv::priv(const std::string &url)
curl(::curl_easy_init()), : curl(::curl_easy_init())
form(nullptr), , form(nullptr)
form_end(nullptr), , form_end(nullptr)
headerlist(nullptr), , headerlist(nullptr)
limit(0), , error_buffer(CURL_ERROR_SIZE + 1, '\0')
cancel(false) , limit(0)
, cancel(false)
{ {
if (curl == nullptr) { if (curl == nullptr) {
throw std::runtime_error(std::string("Could not construct Curl object")); 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_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_USERAGENT, SLIC3R_FORK_NAME "/" SLIC3R_VERSION);
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer.front());
} }
Http::priv::~priv() 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) std::string Http::priv::curl_error(CURLcode curlcode)
{ {
return (boost::format("%1% (%2%)") return (boost::format("%1% (%2%): %3%")
% ::curl_easy_strerror(curlcode) % ::curl_easy_strerror(curlcode)
% curlcode % curlcode
% error_buffer
).str(); ).str();
} }
@ -227,9 +232,7 @@ void Http::priv::http_perform()
::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, static_cast<void*>(this)); ::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, static_cast<void*>(this));
#endif #endif
#ifndef NDEBUG ::curl_easy_setopt(curl, CURLOPT_VERBOSE, get_logging_level() >= 4);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
#endif
if (headerlist != nullptr) { if (headerlist != nullptr) {
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);

View file

@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <thread> #include <thread>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/log/trivial.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <wx/app.h> #include <wx/app.h>
@ -144,6 +145,10 @@ void PrintHostJobQueue::priv::perform_job(PrintHostJob the_job)
{ {
if (bg_exit || the_job.empty()) { return; } 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; const fs::path gcode_path = the_job.upload_data.source_path;
the_job.printhost->upload(std::move(the_job.upload_data), 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); auto evt = new PrintHostQueueDialog::Event(GUI::EVT_PRINTHOST_PROGRESS, queue_dialog->GetId(), job_id, 100);
wxQueueEvent(queue_dialog, evt); 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) void PrintHostJobQueue::enqueue(PrintHostJob job)