diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2013-12-23 15:43:33 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-07 09:39:40 +0100 |
commit | 7e8dc84430426180c7489cf2d29c36ed8b54c0c3 (patch) | |
tree | 48275991756950682244ea7e8fc060e2b8614a89 /src/layouts | |
parent | 6644897dc61f4a15141534c893fd08b12df89bbe (diff) |
Do not loop infinitely if a span is larger than the layout extent
There is no point in searching through all cells to see if an item of
columnSpan 3 fits into a layout with 2 columns, since it won't ever
fit.
So instead we detect this case early and ignore the item for
inclusion.
Task-number: QTBUG-35778
Change-Id: I3f7963df17b05b3eb14ba0bae49e5a885d15b33b
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/layouts')
-rw-r--r-- | src/layouts/qquicklinearlayout.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp index 2b1ce66ec..4f776b1fe 100644 --- a/src/layouts/qquicklinearlayout.cpp +++ b/src/layouts/qquicklinearlayout.cpp @@ -736,6 +736,9 @@ void QQuickGridLayout::insertLayoutItems() Q_ASSERT(columnSpan >= 1); Q_ASSERT(rowSpan >= 1); + const int sp = span[flowOrientation]; + if (sp > flowBound) + return; if (row >= 0) nextRow = row; @@ -758,7 +761,7 @@ void QQuickGridLayout::insertLayoutItems() bool cellAcceptsItem; while (true) { // Check if the item does not span beyond the layout bound - cellAcceptsItem = (flowColumn + span[flowOrientation]) <= flowBound; + cellAcceptsItem = (flowColumn + sp) <= flowBound; // Check if all the required cells are not taken for (int rs = 0; cellAcceptsItem && rs < rowSpan; ++rs) { |