aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel/src')
-rw-r--r--libqmenumodel/src/qmenumodel.cpp9
-rw-r--r--libqmenumodel/src/qmenumodel.h2
2 files changed, 7 insertions, 4 deletions
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index 9a2450c..57c61d0 100644
--- a/libqmenumodel/src/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -51,7 +51,7 @@ QMenuModel::QMenuModel(GMenuModel *other, QObject *parent)
/*! \internal */
QMenuModel::~QMenuModel()
{
- clearModel();
+ clearModel(true);
delete m_cache;
}
@@ -123,7 +123,7 @@ GMenuModel *QMenuModel::menuModel() const
}
/*! \internal */
-void QMenuModel::clearModel()
+void QMenuModel::clearModel(bool destructor)
{
if (m_menuModel) {
g_signal_handler_disconnect(m_menuModel, m_signalChangedId);
@@ -133,7 +133,10 @@ void QMenuModel::clearModel()
}
Q_FOREACH(QMenuModel* child, *m_cache) {
- child->setMenuModel(NULL);
+ // avoid emit signals during the object destruction this can crash qml
+ if (!destructor) {
+ child->setMenuModel(NULL);
+ }
child->deleteLater();
}
m_cache->clear();
diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h
index 54a5c42..f186b5f 100644
--- a/libqmenumodel/src/qmenumodel.h
+++ b/libqmenumodel/src/qmenumodel.h
@@ -72,7 +72,7 @@ private:
QVariant getLink(const QModelIndex &index, const QString &linkName) const;
QVariant getExtraProperties(const QModelIndex &index) const;
QString parseExtraPropertyName(const QString &name) const;
- void clearModel();
+ void clearModel(bool destructor=false);
int count() const;
static void onItemsChanged(GMenuModel *model, gint position, gint removed, gint added, gpointer data);