aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-11-23 18:25:47 +0000
committerTarmac <>2012-11-23 18:25:47 +0000
commit68533d0fedf1bf3a0e6f45230e03222510dd6af6 (patch)
tree78bad3b47623221cdcaf871305f77c71462faa13 /libqmenumodel
parent7cfd1a4cececa6a44aaa3c7c6b35f1886808467e (diff)
parentbdc349d16b6e88c64e6ad16513f33d71bf1a643d (diff)
downloadqmenumodel-68533d0fedf1bf3a0e6f45230e03222510dd6af6.tar.gz
qmenumodel-68533d0fedf1bf3a0e6f45230e03222510dd6af6.tar.bz2
qmenumodel-68533d0fedf1bf3a0e6f45230e03222510dd6af6.zip
Fixed QMenumodel behavior when the GMenuModel is destroyed.
Approved by Lars Uebernickel, PS Jenkins bot.
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/qdbusmenumodel.cpp11
-rw-r--r--libqmenumodel/src/qmenumodel.cpp3
-rw-r--r--libqmenumodel/src/qmenumodel.h1
3 files changed, 8 insertions, 7 deletions
diff --git a/libqmenumodel/src/qdbusmenumodel.cpp b/libqmenumodel/src/qdbusmenumodel.cpp
index 97990b4..b404d0b 100644
--- a/libqmenumodel/src/qdbusmenumodel.cpp
+++ b/libqmenumodel/src/qdbusmenumodel.cpp
@@ -95,13 +95,12 @@ void QDBusMenuModel::serviceVanish(GDBusConnection *)
/*! \internal */
void QDBusMenuModel::serviceAppear(GDBusConnection *connection)
{
- GMenuModel *model = reinterpret_cast<GMenuModel*>(g_dbus_menu_model_get(connection,
- busName().toUtf8().data(),
- objectPath().toUtf8().data()));
+ GMenuModel *model = G_MENU_MODEL(g_dbus_menu_model_get(connection,
+ busName().toUtf8().data(),
+ objectPath().toUtf8().data()));
setMenuModel(model);
- if (model == NULL) {
- stop();
- }
+ //setModel take care of the ref
+ g_object_unref(model);
}
/*! \internal */
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index 8735e6c..ec5570f 100644
--- a/libqmenumodel/src/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -64,6 +64,7 @@ void QMenuModel::setMenuModel(GMenuModel *other)
m_menuModel = other;
if (m_menuModel) {
+ g_object_ref(m_menuModel);
// this will trigger the menu load
(void) g_menu_model_get_n_items(m_menuModel);
m_signalChangedId = g_signal_connect(m_menuModel,
@@ -185,7 +186,7 @@ QVariant QMenuModel::getLink(const QModelIndex &index,
index.row(),
linkName.toUtf8().data());
- if (link) {
+ if (link) {
QMenuModel *other = new QMenuModel(link, const_cast<QMenuModel*>(this));
return QVariant::fromValue<QObject*>(other);
}
diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h
index beec7ba..1ab1e7a 100644
--- a/libqmenumodel/src/qmenumodel.h
+++ b/libqmenumodel/src/qmenumodel.h
@@ -26,6 +26,7 @@ typedef int gint;
typedef unsigned int guint;
typedef void* gpointer;
typedef struct _GMenuModel GMenuModel;
+typedef struct _GObject GObject;
class QMenuModel : public QAbstractListModel
{