aboutsummaryrefslogtreecommitdiff
path: root/libmessaging-menu
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-12-14 19:03:23 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-12-14 19:03:23 +0100
commit871848b6e856244b3396999cf07e24d2397142e5 (patch)
tree359a89328dfeb2b3ce23eea43d09b937ccd90ac1 /libmessaging-menu
parentf609a2715e083f6e3ff3f9b210ad3090a78f43aa (diff)
downloadayatana-indicator-messages-871848b6e856244b3396999cf07e24d2397142e5.tar.gz
ayatana-indicator-messages-871848b6e856244b3396999cf07e24d2397142e5.tar.bz2
ayatana-indicator-messages-871848b6e856244b3396999cf07e24d2397142e5.zip
Make messaging_menu_app_remove_message() work for messages with a ref count of 1
This can happen if noone outside of MessagingMenuApp holds a reference to the message and somebody calls remove_message() with a pointer they got from _get_message() (which doesn't return a ref). messaging_menu_app_remove_message_by_id() really wants a valid 'id' pointer during its lifetime.
Diffstat (limited to 'libmessaging-menu')
-rw-r--r--libmessaging-menu/messaging-menu-app.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libmessaging-menu/messaging-menu-app.c b/libmessaging-menu/messaging-menu-app.c
index 7fc9106..a0180cb 100644
--- a/libmessaging-menu/messaging-menu-app.c
+++ b/libmessaging-menu/messaging-menu-app.c
@@ -1397,7 +1397,11 @@ void
messaging_menu_app_remove_message (MessagingMenuApp *app,
MessagingMenuMessage *msg)
{
+ /* take a ref of @msg here to make sure the pointer returned by
+ * _get_id() is valid for the duration of remove_message_by_id. */
+ g_object_ref (msg);
messaging_menu_app_remove_message_by_id (app, messaging_menu_message_get_id (msg));
+ g_object_unref (msg);
}
/**