From 7a1769409539c7d672af51106d0fa186b32bd0ea Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 1 Oct 2012 17:26:44 +0200 Subject: libmessaging-menu: don't crash when getting an invalid desktop id Instead, silently don't export menus and actions. The single warning about the desktop id being invalid should be enough. --- libmessaging-menu/messaging-menu.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'libmessaging-menu') diff --git a/libmessaging-menu/messaging-menu.c b/libmessaging-menu/messaging-menu.c index 8a95b0a..3c5c6d4 100644 --- a/libmessaging-menu/messaging-menu.c +++ b/libmessaging-menu/messaging-menu.c @@ -148,7 +148,8 @@ messaging_menu_app_get_dbus_object_path (MessagingMenuApp *app) { gchar *path; - g_return_val_if_fail (app->appinfo != NULL, NULL); + if (!app->appinfo) + return NULL; path = g_strconcat ("/com/canonical/indicator/messages/", g_app_info_get_id (G_APP_INFO (app->appinfo)), @@ -170,6 +171,10 @@ export_menus_and_actions (GObject *source, 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) { @@ -178,8 +183,6 @@ export_menus_and_actions (GObject *source, return; } - object_path = messaging_menu_app_get_dbus_object_path (app); - id = g_dbus_connection_export_action_group (bus, object_path, G_ACTION_GROUP (app->source_actions), @@ -479,6 +482,8 @@ messaging_menu_app_register (MessagingMenuApp *app) return; object_path = messaging_menu_app_get_dbus_object_path (app); + if (!object_path) + return; indicator_messages_service_call_register_application (app->messages_service, g_app_info_get_id (G_APP_INFO (app->appinfo)), @@ -510,6 +515,9 @@ messaging_menu_app_unregister (MessagingMenuApp *app) if (!app->messages_service) return; + if (!app->appinfo) + return; + indicator_messages_service_call_unregister_application (app->messages_service, g_app_info_get_id (G_APP_INFO (app->appinfo)), app->cancellable, @@ -546,6 +554,9 @@ messaging_menu_app_set_status (MessagingMenuApp *app, if (!app->messages_service) return; + if (!app->appinfo) + return; + indicator_messages_service_call_set_status (app->messages_service, g_app_info_get_id (G_APP_INFO (app->appinfo)), status_ids [status], -- cgit v1.2.3