summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2010-09-30 09:38:14 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2010-09-30 09:44:20 (GMT)
commitc1f9978c9d61bcbdb2f280185a3abdea13d7f532 (patch)
tree8edd22bd6ca804c8cdaeb7f6a94bdf4b9a191f58
parent3fe98c88473712e1c486f4b93f2ac41b7b07331b (diff)
downloadQt-c1f9978c9d61bcbdb2f280185a3abdea13d7f532.zip
Qt-c1f9978c9d61bcbdb2f280185a3abdea13d7f532.tar.gz
Qt-c1f9978c9d61bcbdb2f280185a3abdea13d7f532.tar.bz2
Fixed a layout issue where you could get NaN as dimensions
The problem is that with empty layouts we could sometimes divide by 0. Note: This doesn't fix the whole task... Task-number: QTBUG-13547 Reviewed-by: ogoffart
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index f3b2026..1e3addc 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -306,20 +306,19 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
ultimatePreferredSize = ultimatePreferredSize * 3 / 2;
ultimateSumPreferredSizes = ultimateSumPreferredSizes * 3 / 2;
- qreal ultimateFactor = (stretch * ultimateSumPreferredSizes
- / sumStretches)
- - (box.q_preferredSize);
- qreal transitionalFactor = sumCurrentAvailable
- * (ultimatePreferredSize - box.q_preferredSize)
- / (ultimateSumPreferredSizes
- - sumPreferredSizes);
-
- qreal alpha = qMin(sumCurrentAvailable,
- ultimateSumPreferredSizes - sumPreferredSizes);
qreal beta = ultimateSumPreferredSizes - sumPreferredSizes;
+ if (!beta) {
+ factors[i] = 1;
+ } else {
+ qreal alpha = qMin(sumCurrentAvailable, beta);
+ qreal ultimateFactor = (stretch * ultimateSumPreferredSizes / sumStretches)
+ - (box.q_preferredSize);
+ qreal transitionalFactor = sumCurrentAvailable * (ultimatePreferredSize - box.q_preferredSize) / beta;
+
+ factors[i] = ((alpha * ultimateFactor)
+ + ((beta - alpha) * transitionalFactor)) / beta;
+ }
- factors[i] = ((alpha * ultimateFactor)
- + ((beta - alpha) * transitionalFactor)) / beta;
}
sumFactors += factors[i];
if (desired < sumCurrentAvailable)