aboutsummaryrefslogtreecommitdiff
path: root/libmessaging-menu
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-10-18 12:37:48 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-10-18 12:37:48 +0200
commite347088b9e4052a037239844e42255f516df305c (patch)
tree596937c23dcee7c98f536925bc55a9ee35001fba /libmessaging-menu
parente271582da5b0d4ba5a69a44f58cdb4b278118ca9 (diff)
parentcad05adc731337b32532b43af127909131a6e582 (diff)
downloadayatana-indicator-messages-e347088b9e4052a037239844e42255f516df305c.tar.gz
ayatana-indicator-messages-e347088b9e4052a037239844e42255f516df305c.tar.bz2
ayatana-indicator-messages-e347088b9e4052a037239844e42255f516df305c.zip
Merge lp:~jconti/indicator-messages/unexport-items
libmessaging-menu: unexport action group and menu model on dispose.
Diffstat (limited to 'libmessaging-menu')
-rw-r--r--libmessaging-menu/messaging-menu.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/libmessaging-menu/messaging-menu.c b/libmessaging-menu/messaging-menu.c
index 6348dcf..59f93a2 100644
--- a/libmessaging-menu/messaging-menu.c
+++ b/libmessaging-menu/messaging-menu.c
@@ -105,9 +105,12 @@ struct _MessagingMenuApp
gboolean status_set;
GSimpleActionGroup *source_actions;
GMenu *menu;
+ GDBusConnection *bus;
IndicatorMessagesService *messages_service;
guint watch_id;
+ guint action_export_id;
+ guint menu_export_id;
GCancellable *cancellable;
};
@@ -166,44 +169,41 @@ export_menus_and_actions (GObject *source,
gpointer user_data)
{
MessagingMenuApp *app = user_data;
- GDBusConnection *bus;
GError *error = NULL;
- guint id;
gchar *object_path;
object_path = messaging_menu_app_get_dbus_object_path (app);
if (!object_path)
return;
- bus = g_bus_get_finish (res, &error);
- if (bus == NULL)
+ app->bus = g_bus_get_finish (res, &error);
+ if (app->bus == NULL)
{
g_warning ("unable to connect to session bus: %s", error->message);
g_error_free (error);
return;
}
- id = g_dbus_connection_export_action_group (bus,
- object_path,
- G_ACTION_GROUP (app->source_actions),
- &error);
- if (!id)
+ app->action_export_id = g_dbus_connection_export_action_group (app->bus,
+ object_path,
+ G_ACTION_GROUP (app->source_actions),
+ &error);
+ if (!app->action_export_id)
{
g_warning ("unable to export action group: %s", error->message);
g_clear_error (&error);
}
- id = g_dbus_connection_export_menu_model (bus,
- object_path,
- G_MENU_MODEL (app->menu),
- &error);
- if (!id)
+ app->menu_export_id = g_dbus_connection_export_menu_model (app->bus,
+ object_path,
+ G_MENU_MODEL (app->menu),
+ &error);
+ if (!app->menu_export_id)
{
g_warning ("unable to export menu: %s", error->message);
g_clear_error (&error);
}
- g_object_unref (bus);
g_free (object_path);
}
@@ -257,6 +257,20 @@ messaging_menu_app_dispose (GObject *object)
{
MessagingMenuApp *app = MESSAGING_MENU_APP (object);
+ if (app->bus)
+ {
+ if (app->action_export_id > 0)
+ g_dbus_connection_unexport_action_group (app->bus, app->action_export_id);
+
+ if (app->menu_export_id > 0)
+ g_dbus_connection_unexport_menu_model (app->bus, app->menu_export_id);
+
+ app->action_export_id = 0;
+ app->menu_export_id = 0;
+ g_object_unref (app->bus);
+ app->bus = NULL;
+ }
+
if (app->watch_id > 0)
{
g_bus_unwatch_name (app->watch_id);
@@ -416,6 +430,10 @@ messaging_menu_app_init (MessagingMenuApp *app)
{
app->registered = -1;
app->status_set = FALSE;
+ app->bus = NULL;
+
+ app->action_export_id = 0;
+ app->menu_export_id = 0;
app->cancellable = g_cancellable_new ();