aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-10-09 15:44:25 -0300
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-10-09 15:44:25 -0300
commitc07f87e35062e39e9d4b3b978362dbf94dd36fbb (patch)
treecd6a396074acc4049f694610d0519c1558bdc796 /libqmenumodel
parenta03e7e775a9751f87efb8fd7acf226b5eb25f4e3 (diff)
downloadqmenumodel-c07f87e35062e39e9d4b3b978362dbf94dd36fbb.tar.gz
qmenumodel-c07f87e35062e39e9d4b3b978362dbf94dd36fbb.tar.bz2
qmenumodel-c07f87e35062e39e9d4b3b978362dbf94dd36fbb.zip
Fixed crash during model destruction in QML.
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/qdbusmenumodel.cpp4
-rw-r--r--libqmenumodel/src/qmenumodel.cpp14
-rw-r--r--libqmenumodel/src/qmenumodel.h2
3 files changed, 12 insertions, 8 deletions
diff --git a/libqmenumodel/src/qdbusmenumodel.cpp b/libqmenumodel/src/qdbusmenumodel.cpp
index ae88c35..6d4746c 100644
--- a/libqmenumodel/src/qdbusmenumodel.cpp
+++ b/libqmenumodel/src/qdbusmenumodel.cpp
@@ -85,7 +85,7 @@ void QDBusMenuModel::stop()
/*! \internal */
void QDBusMenuModel::serviceVanish(GDBusConnection *)
{
- setMenuModel(NULL);
+ setMenuModel(NULL, true);
}
/*! \internal */
@@ -94,7 +94,7 @@ void QDBusMenuModel::serviceAppear(GDBusConnection *connection)
GMenuModel *model = reinterpret_cast<GMenuModel*>(g_dbus_menu_model_get(connection,
busName().toLatin1(),
objectPath().toLatin1()));
- setMenuModel(model);
+ setMenuModel(model, true);
if (model == NULL) {
stop();
}
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index 4c0fc23..cac2f1a 100644
--- a/libqmenumodel/src/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -46,23 +46,25 @@ QMenuModel::QMenuModel(GMenuModel *other, QObject *parent)
rolesNames[Extra] = "extra";
}
setRoleNames(rolesNames);
- setMenuModel(other);
+ setMenuModel(other, true);
}
/*! \internal */
QMenuModel::~QMenuModel()
{
- setMenuModel(NULL);
+ setMenuModel(NULL, false);
}
/*! \internal */
-void QMenuModel::setMenuModel(GMenuModel *other)
+void QMenuModel::setMenuModel(GMenuModel *other, bool notify)
{
if (m_menuModel == other) {
return;
}
- beginResetModel();
+ if (notify) {
+ beginResetModel();
+ }
if (m_menuModel) {
g_signal_handler_disconnect(m_menuModel, m_signalChangedId);
@@ -81,7 +83,9 @@ void QMenuModel::setMenuModel(GMenuModel *other)
this);
}
- endResetModel();
+ if (notify) {
+ endResetModel();
+ }
}
/*! \internal */
diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h
index 7520480..e482e9b 100644
--- a/libqmenumodel/src/qmenumodel.h
+++ b/libqmenumodel/src/qmenumodel.h
@@ -48,7 +48,7 @@ public:
protected:
QMenuModel(GMenuModel *other=0, QObject *parent=0);
- void setMenuModel(GMenuModel *model);
+ void setMenuModel(GMenuModel *model, bool notify);
GMenuModel *menuModel() const;
private: