diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-07-17 15:40:17 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-07-17 15:40:17 +0200 |
commit | 50244fc5d6f0730a447f1ac1ce19827890bc1456 (patch) | |
tree | fd937513dc616c270a1b8da23f982c2b9a7b6ac2 /src/quicktemplates2/qquickpopupanchors.cpp | |
parent | bf727efa7aa9a4738ae86a2c699832129813c670 (diff) | |
parent | 49ffc6e6af83b295c67fd119b79c925879cc292e (diff) |
Merge branch 'dev' into nativestyle
Change-Id: I5375ecd1dcbc058806e34fce757df2bf30dac16e
Diffstat (limited to 'src/quicktemplates2/qquickpopupanchors.cpp')
-rw-r--r-- | src/quicktemplates2/qquickpopupanchors.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopupanchors.cpp b/src/quicktemplates2/qquickpopupanchors.cpp index c48ca5ff..0d286cc0 100644 --- a/src/quicktemplates2/qquickpopupanchors.cpp +++ b/src/quicktemplates2/qquickpopupanchors.cpp @@ -47,6 +47,15 @@ QQuickPopupAnchors::QQuickPopupAnchors(QQuickPopup *popup) d->popup = popup; } +QQuickPopupAnchors::~QQuickPopupAnchors() +{ + Q_D(const QQuickPopupAnchors); + if (d->centerIn) { + auto centerInPrivate = QQuickItemPrivate::get(d->centerIn); + centerInPrivate->removeItemChangeListener(this, QQuickItemPrivate::Destroyed); + } +} + QQuickItem *QQuickPopupAnchors::centerIn() const { Q_D(const QQuickPopupAnchors); @@ -59,8 +68,20 @@ void QQuickPopupAnchors::setCenterIn(QQuickItem *item) if (item == d->centerIn) return; + if (d->centerIn) { + auto centerInPrivate = QQuickItemPrivate::get(d->centerIn); + centerInPrivate->removeItemChangeListener(this, QQuickItemPrivate::Destroyed); + } + d->centerIn = item; + + if (d->centerIn) { + auto centerInPrivate = QQuickItemPrivate::get(d->centerIn); + centerInPrivate->addItemChangeListener(this, QQuickItemPrivate::Destroyed); + } + QQuickPopupPrivate::get(d->popup)->reposition(); + emit centerInChanged(); } @@ -69,6 +90,11 @@ void QQuickPopupAnchors::resetCenterIn() setCenterIn(nullptr); } +void QQuickPopupAnchors::itemDestroyed(QQuickItem *) +{ + resetCenterIn(); +} + QT_END_NAMESPACE #include "moc_qquickpopupanchors_p.cpp" |