[gupnp] NetworkManager context manager impossible to release



Hi,

In the network manager context manager the NMDevice classes keep a
strong reference to the context manager itself leading to a kind of
cyclic reference.

This leads to the problem that it is impossible to unref the
GUPnPNetworkManager completely.

I don't see why it is necessary to keep this strong reference. The
lifetime of the NMDevices doesn't exceed the lifetime of the
GUPnPNetworkManager and all manipulation goes through this class.

Similar for the DBus proxy, though not that critical.

I'm posting this here instead of the bug tracker since I don't exactly
know the purpose of those references and leave it here for discussion

:)
>From b2b1e3d4b695aacfcdce8c075d2b3959118a132a Mon Sep 17 00:00:00 2001
From: Jens Georg <mail jensge org>
Date: Sun, 23 Jan 2011 15:08:32 +0100
Subject: [PATCH] Don't keep strong references in NMDevice

---
 libgupnp/gupnp-network-manager.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libgupnp/gupnp-network-manager.c b/libgupnp/gupnp-network-manager.c
index fc1e0de..80a1c86 100644
--- a/libgupnp/gupnp-network-manager.c
+++ b/libgupnp/gupnp-network-manager.c
@@ -95,8 +95,8 @@ nm_device_new (GUPnPNetworkManager *manager,
 
         nm_device = g_slice_new0 (NMDevice);
 
-        nm_device->manager = g_object_ref (manager);
-        nm_device->proxy = g_object_ref (device_proxy);
+        nm_device->manager = manager;
+        nm_device->proxy = device_proxy;
 
         return nm_device;
 }
@@ -104,7 +104,6 @@ nm_device_new (GUPnPNetworkManager *manager,
 static void
 nm_device_free (NMDevice *nm_device)
 {
-        g_object_unref (nm_device->proxy);
 
         if (nm_device->context != NULL) {
                 g_signal_emit_by_name (nm_device->manager,
@@ -114,7 +113,6 @@ nm_device_free (NMDevice *nm_device)
                 g_object_unref (nm_device->context);
         }
 
-        g_object_unref (nm_device->manager);
 
         g_slice_free (NMDevice, nm_device);
 }
-- 
1.7.3.5



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