Fix bug QGridLayoutEngine::cellRect()

lastColumn and lastRow could exceed the total column/row count, leading
to out-of-bounds accesses to the QList

QGridLayoutEngine::cellRect() is unused, so there is no risk of
regressions here. We fix it because the function might be used later.

So far the plan is to use it for visualizing the layout cells in QtQuick
Layouts.

Change-Id: Idd9db682039f2f81b3a6fbcd03990b6f15334d3e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
Jan Arve Sæther 2025-01-08 16:23:21 +01:00
parent e574cda7fc
commit 0d997213a6

View File

@ -1070,8 +1070,8 @@ QRectF QGridLayoutEngine::cellRect(const QRectF &contentsGeometry, int row, int
ensureGeometries(contentsGeometry.size(), styleInfo);
int lastColumn = qMax(column + columnSpan, columnCount()) - 1;
int lastRow = qMax(row + rowSpan, rowCount()) - 1;
int lastColumn = qMin(column + columnSpan, columnCount()) - 1;
int lastRow = qMin(row + rowSpan, rowCount()) - 1;
qreal x = q_xx[column];
qreal y = q_yy[row];