diff options
-rw-r--r-- | src/quicktemplates2/qquickscrollbar.cpp | 5 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollindicator.cpp | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index f0dd640b..bb29ebd6 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -630,7 +630,10 @@ QQuickScrollBarAttachedPrivate::QQuickScrollBarAttachedPrivate() void QQuickScrollBarAttachedPrivate::setFlickable(QQuickFlickable *item) { if (flickable) { - QQuickItemPrivate::get(flickable)->updateOrRemoveGeometryChangeListener(this, QQuickItemPrivate::Size); + // NOTE: Use removeItemChangeListener(Geometry) instead of updateOrRemoveGeometryChangeListener(Size). + // The latter doesn't remove the listener but only resets its types. Thus, it leaves behind a dangling + // pointer on destruction. + QQuickItemPrivate::get(flickable)->removeItemChangeListener(this, QQuickItemPrivate::Geometry); if (horizontal) cleanupHorizontal(); if (vertical) diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp index c98a1956..a57cfbb6 100644 --- a/src/quicktemplates2/qquickscrollindicator.cpp +++ b/src/quicktemplates2/qquickscrollindicator.cpp @@ -412,6 +412,9 @@ QQuickScrollIndicatorAttached::~QQuickScrollIndicatorAttached() QQuickItemPrivate::get(d->horizontal)->removeItemChangeListener(d, horizontalChangeTypes); if (d->vertical) QQuickItemPrivate::get(d->vertical)->removeItemChangeListener(d,verticalChangeTypes); + // NOTE: Use removeItemChangeListener(Geometry) instead of updateOrRemoveGeometryChangeListener(Size). + // The latter doesn't remove the listener but only resets its types. Thus, it leaves behind a dangling + // pointer on destruction. QQuickItemPrivate::get(d->flickable)->removeItemChangeListener(d, QQuickItemPrivate::Geometry); } } |