aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2/qquickmenu.cpp')
-rw-r--r--src/quicktemplates2/qquickmenu.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index 35dc5dd8..5bc44f0d 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -735,6 +735,16 @@ QQuickMenu::QQuickMenu(QObject *parent)
connect(d->contentModel, &QQmlObjectModel::countChanged, this, &QQuickMenu::countChanged);
}
+QQuickMenu::~QQuickMenu()
+{
+ Q_D(QQuickMenu);
+ // We have to do this to ensure that the change listeners are removed.
+ // It's too late to do this in ~QQuickMenuPrivate, as contentModel has already
+ // been destroyed before that is called.
+ while (d->contentModel->count() > 0)
+ d->removeItem(0, d->itemAt(0));
+}
+
/*!
\qmlmethod Item QtQuick.Controls::Menu::itemAt(int index)