Follow-up of 573194e059
-> Fixed crash when opening a gcode file
This commit is contained in:
parent
014a90b51b
commit
8579184d70
@ -759,13 +759,16 @@ void GCodeProcessor::process_file(const std::string& filename, std::function<voi
|
|||||||
|
|
||||||
// process gcode
|
// process gcode
|
||||||
m_result.id = ++s_result_id;
|
m_result.id = ++s_result_id;
|
||||||
|
// 1st move must be a dummy move
|
||||||
m_result.moves.emplace_back(MoveVertex());
|
m_result.moves.emplace_back(MoveVertex());
|
||||||
m_parser.parse_file(filename, [this, cancel_callback, &last_cancel_callback_time](GCodeReader& reader, const GCodeReader::GCodeLine& line) {
|
m_parser.parse_file(filename, [this, cancel_callback, &last_cancel_callback_time](GCodeReader& reader, const GCodeReader::GCodeLine& line) {
|
||||||
auto curr_time = std::chrono::high_resolution_clock::now();
|
if (cancel_callback != nullptr) {
|
||||||
// call the cancel callback every 100 ms
|
// call the cancel callback every 100 ms
|
||||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - last_cancel_callback_time).count() > 100) {
|
auto curr_time = std::chrono::high_resolution_clock::now();
|
||||||
cancel_callback();
|
if (std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - last_cancel_callback_time).count() > 100) {
|
||||||
last_cancel_callback_time = curr_time;
|
cancel_callback();
|
||||||
|
last_cancel_callback_time = curr_time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
process_gcode_line(line);
|
process_gcode_line(line);
|
||||||
});
|
});
|
||||||
|
@ -420,7 +420,7 @@ namespace Slic3r {
|
|||||||
|
|
||||||
// Process the gcode contained in the file with the given filename
|
// Process the gcode contained in the file with the given filename
|
||||||
// throws CanceledException through print->throw_if_canceled() (sent by the caller as callback).
|
// throws CanceledException through print->throw_if_canceled() (sent by the caller as callback).
|
||||||
void process_file(const std::string& filename, std::function<void()> cancel_callback = std::function<void()>());
|
void process_file(const std::string& filename, std::function<void()> cancel_callback = nullptr);
|
||||||
|
|
||||||
float get_time(PrintEstimatedTimeStatistics::ETimeMode mode) const;
|
float get_time(PrintEstimatedTimeStatistics::ETimeMode mode) const;
|
||||||
std::string get_time_dhm(PrintEstimatedTimeStatistics::ETimeMode mode) const;
|
std::string get_time_dhm(PrintEstimatedTimeStatistics::ETimeMode mode) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user