diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-09-13 22:01:16 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-09-14 00:45:01 +0800 |
commit | 074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8 (patch) | |
tree | 3c5a40b2f196487e6fac7b13c9b3da3d662f3c3f /src/empathy-chat-window.c | |
parent | 733da7c7268c0c77b7cb39701b4f9f1f15d63fd2 (diff) | |
download | gsoc2013-empathy-074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8.tar gsoc2013-empathy-074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8.tar.gz gsoc2013-empathy-074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8.tar.bz2 gsoc2013-empathy-074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8.tar.lz gsoc2013-empathy-074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8.tar.xz gsoc2013-empathy-074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8.tar.zst gsoc2013-empathy-074c63227fd6bd3ce7bae43135d0ff7e2bf37ba8.zip |
Ensure the notification callback data is always freed
Diffstat (limited to 'src/empathy-chat-window.c')
-rw-r--r-- | src/empathy-chat-window.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 5f81ac167..9f596d295 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -59,6 +59,11 @@ #define DEBUG_FLAG EMPATHY_DEBUG_CHAT #include <libempathy/empathy-debug.h> +typedef struct { + EmpathyChatWindow *window; + EmpathyChat *chat; +} NotificationData; + #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatWindow) typedef struct { EmpathyChat *current_chat; @@ -72,6 +77,7 @@ typedef struct { GtkWidget *dialog; GtkWidget *notebook; NotifyNotification *notification; + NotificationData *notification_data; /* Menu items. */ GtkUIManager *ui_manager; @@ -910,10 +916,12 @@ chat_window_set_urgency_hint (EmpathyChatWindow *window, gtk_window_set_urgency_hint (GTK_WINDOW (priv->dialog), urgent); } -typedef struct { - EmpathyChatWindow *window; - EmpathyChat *chat; -} NotificationData; +static void +free_notification_data (NotificationData *data) +{ + g_object_unref (data->chat); + g_slice_free (NotificationData, data); +} static void chat_window_notification_closed_cb (NotifyNotification *notify, @@ -931,8 +939,8 @@ chat_window_notification_closed_cb (NotifyNotification *notify, g_object_unref (notify); priv->notification = NULL; - g_object_unref (cb_data->chat); - g_slice_free (NotificationData, cb_data); + free_notification_data (cb_data); + priv->notification_data = NULL; } static void @@ -972,6 +980,7 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window, cb_data->chat = g_object_ref (chat); cb_data->window = window; + priv->notification_data = cb_data; priv->notification = notify_notification_new (header, escaped, NULL, NULL); notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_DEFAULT); @@ -1365,6 +1374,11 @@ chat_window_finalize (GObject *object) notify_notification_close (priv->notification, NULL); g_object_unref (priv->notification); priv->notification = NULL; + if (priv->notification_data != NULL) + { + free_notification_data (priv->notification_data); + priv->notification_data = NULL; + } } chat_windows = g_list_remove (chat_windows, window); |