aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-12-11 11:55:34 +0000
committerTarmac <>2012-12-11 11:55:34 +0000
commit0f20cc09a72e4d38eb101b649c965b495d255cf3 (patch)
tree41cd582f9a9c2b1db11870325be1da183d9d628a /libqmenumodel
parentb9e5fb6edebc3ee04ad54ce605500ca1dc87949b (diff)
parentd4ce0d48c3d86506291ee8b53edfc4ed6173f5c7 (diff)
downloadqmenumodel-0f20cc09a72e4d38eb101b649c965b495d255cf3.tar.gz
qmenumodel-0f20cc09a72e4d38eb101b649c965b495d255cf3.tar.bz2
qmenumodel-0f20cc09a72e4d38eb101b649c965b495d255cf3.zip
Avoid emit signal during the model reset, this can crash qml.
Approved by PS Jenkins bot, Gustavo Pichorim Boiko.
Diffstat (limited to 'libqmenumodel')
-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);