Do not assert when preferred{Width|Height} is infinity
There's two alternative strategies for fixing this: 1. When fetching the preferred sizes from an item, the number is bounded to a smaller (but still very large) value - not subject to overflow. In practice this will result in the correct layout, but the consequence is a small inconsistency: The preferred size of the layout will be less than infinite despite that one of its items have a preferred size of infinite. 2. Do not bound the fetched preferred sizes from items, but instead let the rest of the code handle infinity. This will result in the correct layout, and also a correct preferred size of the layout. This patch uses the second strategy, by applying a bound when needed. Autotest will be submitted to qtdeclarative, since QGraphicsLayouts are not affected by this. Pick-to: 6.5 6.2 Task-number: QTBUG-116577 Change-Id: I49f79d288370bd93831ac9eda623ce4bbf587796 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> (cherry picked from commit 2a95ecf7e81fbdcfad50f8a1dd5c62b120e2ec27) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit c8df6e18df76a1a60986bfa2266e5c00789059bc)
This commit is contained in:
parent
55d4ee6586
commit
ea8aaf2bc3
@ -13,6 +13,8 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#define LAYOUTITEMSIZE_MAX (1 << 24)
|
||||
|
||||
template<typename T>
|
||||
static void insertOrRemoveItems(QList<T> &items, int index, int delta)
|
||||
{
|
||||
@ -194,7 +196,8 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
|
||||
|
||||
sumAvailable = targetSize - totalBox.q_minimumSize;
|
||||
if (sumAvailable > 0.0) {
|
||||
qreal sumDesired = totalBox.q_preferredSize - totalBox.q_minimumSize;
|
||||
const qreal totalBox_preferredSize = qMin(totalBox.q_preferredSize, qreal(LAYOUTITEMSIZE_MAX));
|
||||
qreal sumDesired = totalBox_preferredSize - totalBox.q_minimumSize;
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (ignore.testBit(start + i)) {
|
||||
@ -203,7 +206,8 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
|
||||
}
|
||||
|
||||
const QGridLayoutBox &box = boxes.at(start + i);
|
||||
qreal desired = box.q_preferredSize - box.q_minimumSize;
|
||||
const qreal box_preferredSize = qMin(box.q_preferredSize, qreal(LAYOUTITEMSIZE_MAX));
|
||||
qreal desired = box_preferredSize - box.q_minimumSize;
|
||||
factors[i] = growthFactorBelowPreferredSize(desired, sumAvailable, sumDesired);
|
||||
sumFactors += factors[i];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user