diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2010-08-11 07:28:32 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2010-08-11 11:28:55 (GMT) |
commit | 98b7e8ac793d95a6a8350c7fc25faebd6f44cd21 (patch) | |
tree | ff7f4e9428bc3c2e02704af8727cbcbed209a4ba /src/gui/graphicsview | |
parent | bb696453f6f87cad58982af3455335478fedb8cc (diff) | |
download | Qt-98b7e8ac793d95a6a8350c7fc25faebd6f44cd21.zip Qt-98b7e8ac793d95a6a8350c7fc25faebd6f44cd21.tar.gz Qt-98b7e8ac793d95a6a8350c7fc25faebd6f44cd21.tar.bz2 |
Layout items had the wrong size if the layout was resized to maximum.
The problem was that if targetSize was the layouts maximum size,
then sumAvailable could be reduced to exactly 0 in the "while
(keepGoing)" loop. That would mean that we would not enter the block
that actually copied the new sizes from the temporary "newSizes" array
to the output "sizes" array due to the "if (sumAvailable > 0)"
condition.
Task-number: none, discovered while fixing QT-3570
Reviewed-by: Frederik Gladhorn
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgridlayoutengine.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index a084647..4fba5ff 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -250,6 +250,7 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz sumAvailable = targetSize - totalBox.q_preferredSize; if (sumAvailable > 0.0) { + qreal sumCurrentAvailable = sumAvailable; bool somethingHasAMaximumSize = false; qreal sumPreferredSizes = 0.0; @@ -308,12 +309,12 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz qreal ultimateFactor = (stretch * ultimateSumPreferredSizes / sumStretches) - (box.q_preferredSize); - qreal transitionalFactor = sumAvailable + qreal transitionalFactor = sumCurrentAvailable * (ultimatePreferredSize - box.q_preferredSize) / (ultimateSumPreferredSizes - sumPreferredSizes); - qreal alpha = qMin(sumAvailable, + qreal alpha = qMin(sumCurrentAvailable, ultimateSumPreferredSizes - sumPreferredSizes); qreal beta = ultimateSumPreferredSizes - sumPreferredSizes; @@ -321,7 +322,7 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz + ((beta - alpha) * transitionalFactor)) / beta; } sumFactors += factors[i]; - if (desired < sumAvailable) + if (desired < sumCurrentAvailable) somethingHasAMaximumSize = true; newSizes[i] = -1.0; @@ -337,12 +338,12 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz continue; const QGridLayoutBox &box = boxes.at(start + i); - qreal avail = sumAvailable * factors[i] / sumFactors; + qreal avail = sumCurrentAvailable * factors[i] / sumFactors; if (sizes[i] + avail >= box.q_maximumSize) { newSizes[i] = box.q_maximumSize; - sumAvailable -= box.q_maximumSize - sizes[i]; + sumCurrentAvailable -= box.q_maximumSize - sizes[i]; sumFactors -= factors[i]; - keepGoing = (sumAvailable > 0.0); + keepGoing = (sumCurrentAvailable > 0.0); if (!keepGoing) break; } @@ -352,7 +353,7 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz for (int i = 0; i < n; ++i) { if (newSizes[i] < 0.0) { qreal delta = (sumFactors == 0.0) ? 0.0 - : sumAvailable * factors[i] / sumFactors; + : sumCurrentAvailable * factors[i] / sumFactors; newSizes[i] = sizes[i] + delta; } } |