aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-06-29 12:08:42 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-06-30 10:08:03 +0200
commitf3452af843fbb50718d60dc4b2726bc156b2b44c (patch)
treed09a5667dece1cc86a37a165a83cc5d9add10728 /src/quick/items
parent6616008e2e3de940bcd551ad2832ebfed2b9e063 (diff)
QQuickItemPrivate: Make {width,height}Valid a function
There is now some additional logic, so we cannot simply rely on the boolean flag. Task-number: QTBUG-94703 Pick-to: 6.2 Change-Id: Id4674efd205a58b015a82b3c06e63c8a031f6607 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickitem.cpp20
-rw-r--r--src/quick/items/qquickitem_p.h7
-rw-r--r--src/quick/items/qquickloader.cpp4
-rw-r--r--src/quick/items/qquickstateoperations.cpp8
4 files changed, 21 insertions, 18 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index ff269363bb..f5fe3f466b 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -3177,8 +3177,8 @@ QQuickItemPrivate::QQuickItemPrivate()
: _anchors(nullptr)
, _stateGroup(nullptr)
, flags(0)
- , widthValid(false)
- , heightValid(false)
+ , widthValidFlag(false)
+ , heightValidFlag(false)
, componentComplete(true)
, keepMouse(false)
, keepTouch(false)
@@ -6887,7 +6887,7 @@ void QQuickItem::setWidth(qreal w)
if (qt_is_nan(w))
return;
- d->widthValid = true;
+ d->widthValidFlag = true;
if (d->width == w)
return;
@@ -6904,7 +6904,7 @@ void QQuickItem::resetWidth()
{
Q_D(QQuickItem);
d->width.takeBinding();
- d->widthValid = false;
+ d->widthValidFlag = false;
setImplicitWidth(implicitWidth());
}
@@ -7062,7 +7062,7 @@ bool QQuickItem::widthValid() const
See QQmlPropertyBinding::isUndefined and handleUndefinedAssignment
*/
- return d->widthValid || d->width.hasBinding();
+ return d->widthValid();
}
/*!
@@ -7086,7 +7086,7 @@ void QQuickItem::setHeight(qreal h)
if (qt_is_nan(h))
return;
- d->heightValid = true;
+ d->heightValidFlag = true;
if (d->height == h)
return;
@@ -7106,7 +7106,7 @@ void QQuickItem::resetHeight()
// property, but preserve the existing value (and avoid some overhead
// compared to calling setHeight(height())
d->height.takeBinding();
- d->heightValid = false;
+ d->heightValidFlag = false;
setImplicitHeight(implicitHeight());
}
@@ -7231,7 +7231,7 @@ void QQuickItem::setImplicitSize(qreal w, qreal h)
bool QQuickItem::heightValid() const
{
Q_D(const QQuickItem);
- return d->heightValid || d->height.hasBinding();
+ return d->heightValid();
}
/*!
@@ -7262,8 +7262,8 @@ QSizeF QQuickItem::size() const
void QQuickItem::setSize(const QSizeF &size)
{
Q_D(QQuickItem);
- d->heightValid = true;
- d->widthValid = true;
+ d->heightValidFlag = true;
+ d->widthValidFlag = true;
if (d->width == size.width() && d->height == size.height())
return;
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index de6bb4aedd..3004fcd70d 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -441,8 +441,8 @@ public:
// Bit 0
quint32 flags:5;
- bool widthValid:1;
- bool heightValid:1;
+ bool widthValidFlag:1;
+ bool heightValidFlag:1;
bool componentComplete:1;
bool keepMouse:1;
bool keepTouch:1;
@@ -578,6 +578,9 @@ public:
qreal implicitWidth;
qreal implicitHeight;
+ bool widthValid() const { return widthValidFlag || width.hasBinding(); }
+ bool heightValid() const { return heightValidFlag || height.hasBinding(); }
+
qreal baselineOffset;
QList<QQuickTransform *> transforms;
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index d5a822c26f..4cd93ca1f0 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -650,9 +650,9 @@ void QQuickLoaderPrivate::setInitialState(QObject *obj)
// does, then set the item's size now before bindings are
// evaluated, otherwise we will end up resizing the item
// later and triggering any affected bindings/anchors.
- if (widthValid && !QQuickItemPrivate::get(item)->widthValid)
+ if (widthValid() && !QQuickItemPrivate::get(item)->widthValid())
item->setWidth(q->width());
- if (heightValid && !QQuickItemPrivate::get(item)->heightValid)
+ if (heightValid() && !QQuickItemPrivate::get(item)->heightValid())
item->setHeight(q->height());
item->setParentItem(q);
}
diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp
index 34c5b46892..bfec619f80 100644
--- a/src/quick/items/qquickstateoperations.cpp
+++ b/src/quick/items/qquickstateoperations.cpp
@@ -1198,9 +1198,9 @@ void QQuickAnchorChanges::saveOriginals()
d->origBaselineBinding = QQmlPropertyPrivate::binding(d->baselineProp);
QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target);
- if (targetPrivate->widthValid)
+ if (targetPrivate->widthValid())
d->origWidth = d->target->width();
- if (targetPrivate->heightValid)
+ if (targetPrivate->heightValid())
d->origHeight = d->target->height();
d->origX = d->target->x();
d->origY = d->target->y();
@@ -1332,10 +1332,10 @@ void QQuickAnchorChanges::rewind()
//restore previous values (but not previous bindings, i.e. anchors)
d->target->setX(d->rewindX);
d->target->setY(d->rewindY);
- if (targetPrivate->widthValid) {
+ if (targetPrivate->widthValid()) {
d->target->setWidth(d->rewindWidth);
}
- if (targetPrivate->heightValid) {
+ if (targetPrivate->heightValid()) {
d->target->setHeight(d->rewindHeight);
}
}