[gnome-control-center/gnome-3-2] Printers: Store DBus subscription id for unsubscription



commit 81fb28de5cf8708932224f482a8923322191b00f
Author: Marek Kasik <mkasik redhat com>
Date:   Mon Nov 28 15:43:02 2011 +0100

    Printers: Store DBus subscription id for unsubscription
    
    Store subscription id returned by g_dbus_connection_signal_subscribe()
    and unsubscribe the signal with it when not needed any more. This should
    fix rhbz #752168.

 panels/printers/cc-printers-panel.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 8314fe6..098647a 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -90,6 +90,7 @@ struct _CcPrintersPanelPrivate
   gint             subscription_id;
   guint            subscription_renewal_id;
   guint            cups_status_check_id;
+  guint            dbus_subscription_id;
 
   gpointer dummy;
 };
@@ -388,16 +389,17 @@ attach_to_cups_notifier (gpointer data)
 
       priv->cups_bus_connection = g_dbus_proxy_get_connection (priv->cups_proxy);
 
-      g_dbus_connection_signal_subscribe (priv->cups_bus_connection,
-                                          NULL,
-                                          CUPS_DBUS_INTERFACE,
-                                          NULL,
-                                          CUPS_DBUS_PATH,
-                                          NULL,
-                                          0,
-                                          on_cups_notification,
-                                          self,
-                                          NULL);
+      priv->dbus_subscription_id =
+        g_dbus_connection_signal_subscribe (priv->cups_bus_connection,
+                                            NULL,
+                                            CUPS_DBUS_INTERFACE,
+                                            NULL,
+                                            CUPS_DBUS_PATH,
+                                            NULL,
+                                            0,
+                                            on_cups_notification,
+                                            self,
+                                            NULL);
     }
 }
 
@@ -409,6 +411,12 @@ detach_from_cups_notifier (gpointer data)
 
   priv = PRINTERS_PANEL_PRIVATE (self);
 
+  if (priv->dbus_subscription_id != 0) {
+    g_dbus_connection_signal_unsubscribe (priv->cups_bus_connection,
+                                          priv->dbus_subscription_id);
+    priv->dbus_subscription_id = 0;
+  }
+
   cancel_cups_subscription (priv->subscription_id);
   priv->subscription_id = 0;
 
@@ -2475,6 +2483,7 @@ cc_printers_panel_init (CcPrintersPanel *self)
   priv->subscription_renewal_id = 0;
   priv->cups_proxy = NULL;
   priv->cups_bus_connection = NULL;
+  priv->dbus_subscription_id = 0;
 
   priv->permission = NULL;
   priv->lockdown_settings = NULL;



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