diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-12-11 11:09:49 +0000 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-12-11 11:09:49 +0000 |
commit | d4ce0d48c3d86506291ee8b53edfc4ed6173f5c7 (patch) | |
tree | 41cd582f9a9c2b1db11870325be1da183d9d628a | |
parent | b9e5fb6edebc3ee04ad54ce605500ca1dc87949b (diff) | |
download | qmenumodel-d4ce0d48c3d86506291ee8b53edfc4ed6173f5c7.tar.gz qmenumodel-d4ce0d48c3d86506291ee8b53edfc4ed6173f5c7.tar.bz2 qmenumodel-d4ce0d48c3d86506291ee8b53edfc4ed6173f5c7.zip |
Avoid emit signal during the model reset, this can crash qml.
-rw-r--r-- | libqmenumodel/src/qmenumodel.cpp | 9 | ||||
-rw-r--r-- | libqmenumodel/src/qmenumodel.h | 2 |
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); |