Fixed a crash in GCodeViewer (SPE-2052, #11728)

This commit is contained in:
Lukas Matena 2023-11-23 11:55:57 +01:00
parent 0a1e4758a1
commit a99dd7b00b

View File

@ -492,9 +492,10 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s
const size_t ref_id = (i == 0) ? 0 : i - 1; const size_t ref_id = (i == 0) ? 0 : i - 1;
const size_t first_line_id = (i == 0) ? *m_cache_range.min : const size_t first_line_id = (i == 0) ? *m_cache_range.min :
(*m_cache_range.min - 1 >= cumulative_lines_counts[ref_id]) ? *m_cache_range.min - cumulative_lines_counts[ref_id] : 1; (*m_cache_range.min > cumulative_lines_counts[ref_id]) ? *m_cache_range.min - cumulative_lines_counts[ref_id] : 1;
const size_t last_line_id = (*m_cache_range.max - 1 <= cumulative_lines_counts[i]) ? const size_t last_line_id = (*m_cache_range.max <= cumulative_lines_counts[i]) ?
(i == 0) ? *m_cache_range.max : *m_cache_range.max - cumulative_lines_counts[ref_id] : m_lines_ends[i].size() - 1; (i == 0) ? *m_cache_range.max : *m_cache_range.max - cumulative_lines_counts[ref_id] : m_lines_ends[i].size();
assert(last_line_id >= first_line_id);
for (size_t j = first_line_id; j <= last_line_id; ++j) { for (size_t j = first_line_id; j <= last_line_id; ++j) {
const size_t begin = (j == 1) ? 0 : m_lines_ends[i][j - 2]; const size_t begin = (j == 1) ? 0 : m_lines_ends[i][j - 2];