diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-12-14 18:47:25 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2012-12-14 18:47:25 +0000 |
commit | 33f539cf60c3f574f5b744361155f4ecd0ff0a6d (patch) | |
tree | 359a89328dfeb2b3ce23eea43d09b937ccd90ac1 | |
parent | f609a2715e083f6e3ff3f9b210ad3090a78f43aa (diff) | |
parent | 871848b6e856244b3396999cf07e24d2397142e5 (diff) | |
download | ayatana-indicator-messages-33f539cf60c3f574f5b744361155f4ecd0ff0a6d.tar.gz ayatana-indicator-messages-33f539cf60c3f574f5b744361155f4ecd0ff0a6d.tar.bz2 ayatana-indicator-messages-33f539cf60c3f574f5b744361155f4ecd0ff0a6d.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.
Approved by PS Jenkins bot, Gustavo Pichorim Boiko.
-rw-r--r-- | libmessaging-menu/messaging-menu-app.c | 4 |
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); } /** |