[gnome-settings-daemon] updates: Don't leak notification objects



commit c2fc6103234aa04e234071839ebdecdb176f55d3
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 29 23:59:34 2012 -0400

    updates: Don't leak notification objects
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 plugins/updates/gsd-updates-firmware.c |   17 ++++++++++++++++-
 plugins/updates/gsd-updates-manager.c  |   17 +++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/plugins/updates/gsd-updates-firmware.c b/plugins/updates/gsd-updates-firmware.c
index a04ad27..140a86d 100644
--- a/plugins/updates/gsd-updates-firmware.c
+++ b/plugins/updates/gsd-updates-firmware.c
@@ -213,7 +213,6 @@ out:
         g_string_free (string, TRUE);
         return ret;
 }
-
 static void
 libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data)
 {
@@ -226,6 +225,13 @@ libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data)
         } else {
                 g_warning ("unknown action id: %s", action);
         }
+        notify_notification_close (notification, NULL);
+}
+
+static void
+on_notification_closed (NotifyNotification *notification, gpointer data)
+{
+        g_object_unref (notification);
 }
 
 static void
@@ -244,6 +250,8 @@ require_restart (GsdUpdatesFirmware *firmware)
         notify_notification_set_app_name (notification, _("Software Updates"));
         notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
         notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
 
         /* show the bubble */
         ret = notify_notification_show (notification, &error);
@@ -269,6 +277,8 @@ require_replug (GsdUpdatesFirmware *firmware)
         notify_notification_set_app_name (notification, _("Software Updates"));
         notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
         notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
 
         /* show the bubble */
         ret = notify_notification_show (notification, &error);
@@ -294,6 +304,8 @@ require_nothing (GsdUpdatesFirmware *firmware)
         notify_notification_set_app_name (notification, _("Software Updates"));
         notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
         notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
 
         /* show the bubble */
         ret = notify_notification_show (notification, &error);
@@ -589,6 +601,9 @@ delay_timeout_cb (gpointer data)
         notify_notification_add_action (notification, "ignore-devices",
                                         /* TRANSLATORS: we should ignore this device and not ask anymore */
                                         _("Ignore devices"), libnotify_cb, firmware, NULL);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
+
         ret = notify_notification_show (notification, &error);
         if (!ret) {
                 g_warning ("error: %s", error->message);
diff --git a/plugins/updates/gsd-updates-manager.c b/plugins/updates/gsd-updates-manager.c
index 7f8c49b..a3d833f 100644
--- a/plugins/updates/gsd-updates-manager.c
+++ b/plugins/updates/gsd-updates-manager.c
@@ -200,6 +200,7 @@ libnotify_action_cb (NotifyNotification *notification,
         GError *error = NULL;
         GsdUpdatesManager *manager = GSD_UPDATES_MANAGER (user_data);
 
+        notify_notification_close (notification, NULL);
         if (g_strcmp0 (action, "distro-upgrade-info") == 0) {
                 ret = g_spawn_command_line_async (DATADIR "/PackageKit/pk-upgrade-distro.sh",
                                                   &error);
@@ -247,6 +248,12 @@ out:
 }
 
 static void
+on_notification_closed (NotifyNotification *notification, gpointer data)
+{
+        g_object_unref (notification);
+}
+
+static void
 get_distro_upgrades_finished_cb (GObject *object,
                                  GAsyncResult *res,
                                  GsdUpdatesManager *manager)
@@ -332,6 +339,8 @@ get_distro_upgrades_finished_cb (GObject *object,
                                         _("More information"),
                                         libnotify_action_cb,
                                         manager, NULL);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
         ret = notify_notification_show (notification, &error);
         if (!ret) {
                 g_warning ("error: %s", error->message);
@@ -455,6 +464,8 @@ notify_critical_updates (GsdUpdatesManager *manager, GPtrArray *array)
         notify_notification_add_action (notification, "show-update-viewer",
                                         /* TRANSLATORS: button: open the update viewer to install updates*/
                                         _("Install updates"), libnotify_action_cb, manager, NULL);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
         ret = notify_notification_show (notification, &error);
         if (!ret) {
                 g_warning ("error: %s", error->message);
@@ -514,6 +525,8 @@ notify_normal_updates_maybe (GsdUpdatesManager *manager, GPtrArray *array)
         notify_notification_add_action (notification, "show-update-viewer",
                                         /* TRANSLATORS: button: open the update viewer to install updates*/
                                         _("Install updates"), libnotify_action_cb, manager, NULL);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
         ret = notify_notification_show (notification, &error);
         if (!ret) {
                 g_warning ("error: %s", error->message);
@@ -602,6 +615,8 @@ notify_failed_get_updates_maybe (GsdUpdatesManager *manager)
                                         button,
                                         libnotify_action_cb,
                                         manager, NULL);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
         ret = notify_notification_show (notification, &error);
         if (!ret) {
                 g_warning ("failed to show notification: %s",
@@ -1297,6 +1312,8 @@ check_offline_update_cb (gpointer user_data)
         notify_notification_add_action (notification, "clear-offline-updates",
                                         /* TRANSLATORS: button: clear notification */
                                         _("OK"), libnotify_action_cb, manager, NULL);
+        g_signal_connect (notification, "closed",
+                          G_CALLBACK (on_notification_closed), NULL);
         ret = notify_notification_show (notification, &error);
         if (!ret) {
                 g_warning ("error: %s", error->message);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]