From 07e7e115901c80f282b06ea6b86bc56b28e1a02b Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 27 Sep 2021 10:02:48 +0200 Subject: [PATCH] Fix of prusa-gcodeviewer changes modification time of the viewed gcode file #7005 This is a regression wrt. PrusaSlicer 2.4.0-alpha1 due to the G-code processing optimization and parallelization. Related to GCode Viewer changes files modified date in windows #5079 --- src/libslic3r/GCode/GCodeProcessor.cpp | 10 +++++++--- src/libslic3r/GCode/GCodeProcessor.hpp | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 4e731c8b4..55c41f8fe 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1189,6 +1189,8 @@ static inline const char* remove_eols(const char *begin, const char *end) { return end; } +// Load a G-code into a stand-alone G-code viewer. +// throws CanceledException through print->throw_if_canceled() (sent by the caller as callback). void GCodeProcessor::process_file(const std::string& filename, std::function cancel_callback) { CNumericLocalesSetter locales_setter; @@ -1243,7 +1245,8 @@ void GCodeProcessor::process_file(const std::string& filename, std::functionprocess_gcode_line(line, true); }); - this->finalize(); + // Don't post-process the G-code to update time stamps. + this->finalize(false); } void GCodeProcessor::initialize(const std::string& filename) @@ -1269,7 +1272,7 @@ void GCodeProcessor::process_buffer(const std::string &buffer) }); } -void GCodeProcessor::finalize() +void GCodeProcessor::finalize(bool post_process) { // update width/height of wipe moves for (MoveVertex& move : m_result.moves) { @@ -1299,7 +1302,8 @@ void GCodeProcessor::finalize() m_width_compare.output(); #endif // ENABLE_GCODE_VIEWER_DATA_CHECKING - m_time_processor.post_process(m_result.filename, m_result.moves, m_result.lines_ends); + if (post_process) + m_time_processor.post_process(m_result.filename, m_result.moves, m_result.lines_ends); #if ENABLE_GCODE_VIEWER_STATISTICS m_result.time = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - m_start_time).count(); #endif // ENABLE_GCODE_VIEWER_STATISTICS diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 5af040307..0639567ea 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -579,14 +579,14 @@ namespace Slic3r { const Result& get_result() const { return m_result; } Result&& extract_result() { return std::move(m_result); } - // Process the gcode contained in the file with the given filename + // Load a G-code into a stand-alone G-code viewer. // throws CanceledException through print->throw_if_canceled() (sent by the caller as callback). void process_file(const std::string& filename, std::function cancel_callback = nullptr); // Streaming interface, for processing G-codes just generated by PrusaSlicer in a pipelined fashion. void initialize(const std::string& filename); void process_buffer(const std::string& buffer); - void finalize(); + void finalize(bool post_process); float get_time(PrintEstimatedStatistics::ETimeMode mode) const; std::string get_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const;