Maemo: Properly unregister the RPC callbacks.
authorTobias Brunner <tobias@strongswan.org>
Thu, 30 Sep 2010 11:43:58 +0000 (13:43 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 14 Oct 2010 15:36:19 +0000 (17:36 +0200)
src/frontends/maemo/src/strongswan-status.c
src/libcharon/plugins/maemo/maemo_service.c

index c77de8c..f9a0b76 100644 (file)
@@ -532,34 +532,30 @@ strongswan_status_init (StrongswanStatus *plugin)
        gtk_widget_show_all (GTK_WIDGET (plugin));
 }
 
+#define UNREF_IF(obj) do { \
+       if (obj) { obj = (g_object_unref (obj), NULL); } \
+} while(0)
+
 static void
 strongswan_status_dispose (GObject *object)
 {
        StrongswanStatusPrivate *priv = STRONGSWAN_STATUS (object)->priv;
-       if (priv->conns)
-       {
-               priv->conns = (g_object_unref (priv->conns), NULL);
-       }
-       if (priv->icons.status_open)
-       {
-               g_object_unref (priv->icons.status_open);
-               priv->icons.status_open = NULL;
-       }
-       if (priv->icons.status_close)
-       {
-               g_object_unref (priv->icons.status_close);
-               priv->icons.status_close = NULL;
-       }
-       if (priv->icons.button_open)
-       {
-               g_object_unref (priv->icons.button_open);
-               priv->icons.button_open = NULL;
-       }
-       if (priv->icons.button_close)
+       if (priv->context)
        {
-               g_object_unref (priv->icons.button_close);
-               priv->icons.button_close = NULL;
+               osso_rpc_unset_cb_f (priv->context,
+                                                        OSSO_STATUS_SERVICE,
+                                                        OSSO_STATUS_OBJECT,
+                                                        OSSO_STATUS_IFACE,
+                                                        (osso_rpc_cb_f*)dbus_req_handler,
+                                                        STRONGSWAN_STATUS (object));
+               osso_deinitialize (priv->context);
+               priv->context = NULL;
        }
+       UNREF_IF(priv->conns);
+       UNREF_IF(priv->icons.status_open);
+       UNREF_IF(priv->icons.status_close);
+       UNREF_IF(priv->icons.button_open);
+       UNREF_IF(priv->icons.button_close);
        G_OBJECT_CLASS (strongswan_status_parent_class)->dispose (object);
 }
 
index ad150d7..3dc6129 100644 (file)
@@ -318,6 +318,12 @@ METHOD(maemo_service_t, destroy, void,
        }
        if (this->context)
        {
+               osso_rpc_unset_cb_f(this->context,
+                                                       OSSO_CHARON_SERVICE,
+                                                       OSSO_CHARON_OBJECT,
+                                                       OSSO_CHARON_IFACE,
+                                                       (osso_rpc_cb_f*)dbus_req_handler,
+                                                       this);
                osso_deinitialize(this->context);
        }
        charon->bus->remove_listener(charon->bus, &this->public.listener);