diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-10-16 07:56:41 +0000 |
---|---|---|
committer | Tarmac <> | 2012-10-16 07:56:41 +0000 |
commit | 340e67d86483b2038d087b6ff2615e0d5c7cc5cc (patch) | |
tree | 5043b5daf97aa9e2bb2e87e7d5809b3a762e556e /libqmenumodel/src/qmenumodel.cpp | |
parent | 5999e7a42962140b6479995d77a178186b6b2fcc (diff) | |
parent | 5c56d1288ba905ab162246c65fffbc69a831a14e (diff) | |
download | qmenumodel-340e67d86483b2038d087b6ff2615e0d5c7cc5cc.tar.gz qmenumodel-340e67d86483b2038d087b6ff2615e0d5c7cc5cc.tar.bz2 qmenumodel-340e67d86483b2038d087b6ff2615e0d5c7cc5cc.zip |
Avoid emit model reset during QMenuModel destructor, to avoid crash in QML engine.. Approved by Olivier Tilloy, PS Jenkins bot, jenkins.
Diffstat (limited to 'libqmenumodel/src/qmenumodel.cpp')
-rw-r--r-- | libqmenumodel/src/qmenumodel.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp index 1aaf210..a45e5ff 100644 --- a/libqmenumodel/src/qmenumodel.cpp +++ b/libqmenumodel/src/qmenumodel.cpp @@ -56,7 +56,7 @@ QMenuModel::QMenuModel(GMenuModel *other, QObject *parent) /*! \internal */ QMenuModel::~QMenuModel() { - setMenuModel(NULL); + clearModel(); } /*! \internal */ @@ -68,11 +68,7 @@ void QMenuModel::setMenuModel(GMenuModel *other) beginResetModel(); - if (m_menuModel) { - g_signal_handler_disconnect(m_menuModel, m_signalChangedId); - m_signalChangedId = 0; - g_object_unref(m_menuModel); - } + clearModel(); m_menuModel = other; @@ -95,6 +91,17 @@ GMenuModel *QMenuModel::menuModel() const } /*! \internal */ +void QMenuModel::clearModel() +{ + if (m_menuModel) { + g_signal_handler_disconnect(m_menuModel, m_signalChangedId); + m_signalChangedId = 0; + g_object_unref(m_menuModel); + m_menuModel = NULL; + } +} + +/*! \internal */ QVariant QMenuModel::data(const QModelIndex &index, int role) const { QVariant attribute; |