diff options
Diffstat (limited to 'libqmenumodel/src')
-rw-r--r-- | libqmenumodel/src/qdbusmenumodel.cpp | 11 | ||||
-rw-r--r-- | libqmenumodel/src/qmenumodel.cpp | 3 | ||||
-rw-r--r-- | libqmenumodel/src/qmenumodel.h | 1 |
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 { |