Skip to content

Commit a99dd7b

Browse files
committed
Fixed a crash in GCodeViewer (SPE-2052, #11728)
1 parent 0a1e475 commit a99dd7b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/slic3r/GUI/GCodeViewer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,10 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s
492492

493493
const size_t ref_id = (i == 0) ? 0 : i - 1;
494494
const size_t first_line_id = (i == 0) ? *m_cache_range.min :
495-
(*m_cache_range.min - 1 >= cumulative_lines_counts[ref_id]) ? *m_cache_range.min - cumulative_lines_counts[ref_id] : 1;
496-
const size_t last_line_id = (*m_cache_range.max - 1 <= cumulative_lines_counts[i]) ?
497-
(i == 0) ? *m_cache_range.max : *m_cache_range.max - cumulative_lines_counts[ref_id] : m_lines_ends[i].size() - 1;
495+
(*m_cache_range.min > cumulative_lines_counts[ref_id]) ? *m_cache_range.min - cumulative_lines_counts[ref_id] : 1;
496+
const size_t last_line_id = (*m_cache_range.max <= cumulative_lines_counts[i]) ?
497+
(i == 0) ? *m_cache_range.max : *m_cache_range.max - cumulative_lines_counts[ref_id] : m_lines_ends[i].size();
498+
assert(last_line_id >= first_line_id);
498499

499500
for (size_t j = first_line_id; j <= last_line_id; ++j) {
500501
const size_t begin = (j == 1) ? 0 : m_lines_ends[i][j - 2];

0 commit comments

Comments
 (0)