diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-02-22 10:40:10 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2017-02-22 11:02:52 +0000 |
commit | b17337da34a76f9512a826b19dcd45b337295c3b (patch) | |
tree | bf43a68496acb08366eeb6c36f5c8800b5a1645e /src/imports | |
parent | 2a15f6c5de6905b2b0b583c0d37d109eeb94c196 (diff) |
QQuickLayout: ensure that all change listeners are removed
The first fix for QTBUG-51927 (59c6c0e0) went to 5.6.2, where only the
SiblingOrder ChangeType was listened to by QQuickLayout. It was then
cherry-picked to 5.7 (5149aa68), where SiblingOrder was still the only
ChangeType in use.
3b4f00ec then optimized QQuickLayout by swapping connections for item
change listeners, but didn't check for usages of change types elsewhere
in the file.
This patch moves the change types into a variable that ensures there
is one place for future changes. 5.6 is not affected.
Task-number: QTBUG-51927
Change-Id: Ifd6e0545ce543ab79d6415e007b35c457cacc83a
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/layouts/qquicklayout.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp index 55ee3b63c6..df64b593d9 100644 --- a/src/imports/layouts/qquicklayout.cpp +++ b/src/imports/layouts/qquicklayout.cpp @@ -696,13 +696,20 @@ QQuickLayout::QQuickLayout(QQuickLayoutPrivate &dd, QQuickItem *parent) { } +static QQuickItemPrivate::ChangeTypes changeTypes = + QQuickItemPrivate::SiblingOrder + | QQuickItemPrivate::ImplicitWidth + | QQuickItemPrivate::ImplicitHeight + | QQuickItemPrivate::Destroyed + | QQuickItemPrivate::Visibility; + QQuickLayout::~QQuickLayout() { d_func()->m_isReady = false; const auto childItems = d_func()->childItems; for (QQuickItem *child : childItems) - QQuickItemPrivate::get(child)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder); + QQuickItemPrivate::get(child)->removeItemChangeListener(this, changeTypes); } QQuickLayoutAttached *QQuickLayout::qmlAttachedProperties(QObject *object) @@ -766,14 +773,14 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) Q_D(QQuickLayout); QQuickItem *item = value.item; qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem())); - QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); + QQuickItemPrivate::get(item)->addItemChangeListener(this, changeTypes); d->m_hasItemChangeListeners = true; if (isReady()) updateLayoutItems(); } else if (change == ItemChildRemovedChange) { QQuickItem *item = value.item; qmlobject_disconnect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem())); - QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); + QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes); if (isReady()) updateLayoutItems(); } @@ -821,7 +828,7 @@ void QQuickLayout::deactivateRecur() // When deleting a layout with children, there is no reason for the children to inform the layout that their // e.g. visibility got changed. The layout already knows that all its children will eventually become invisible, so // we therefore remove its change listener. - QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); + QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes); if (QQuickLayout *layout = qobject_cast<QQuickLayout*>(item)) layout->deactivateRecur(); } |