From 7cd402dcd0e9ec71ea5ea4a368f7d53eaafecbbf Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 21 Jul 2021 08:58:14 +0200 Subject: [PATCH] GCodeViewer -> Fixed crash when importing gcode files generated by older versions of PrusaSlicer --- src/slic3r/GUI/GCodeViewer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 1a48562d9..51a41b046 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -3429,11 +3429,17 @@ void GCodeViewer::render_legend() const std::string first_str = _u8L("First layer"); std::string total_str = _u8L("Total"); - float max_len = 10.0f + ImGui::GetStyle().ItemSpacing.x + std::max(ImGui::CalcTextSize(first_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x); + float max_len = 10.0f + ImGui::GetStyle().ItemSpacing.x; + if (time_mode.layers_times.empty()) + max_len += ImGui::CalcTextSize(total_str.c_str()).x; + else + max_len += std::max(ImGui::CalcTextSize(first_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x); - imgui.text(first_str + ":"); - ImGui::SameLine(max_len); - imgui.text(short_time(get_time_dhms(time_mode.layers_times.front()))); + if (!time_mode.layers_times.empty()) { + imgui.text(first_str + ":"); + ImGui::SameLine(max_len); + imgui.text(short_time(get_time_dhms(time_mode.layers_times.front()))); + } imgui.text(total_str + ":"); ImGui::SameLine(max_len);