[tracker/harmattan-pre-signal-updates: 1305/1380] libtracker-miner, miners/fs: Don't keep DBusGProxy instancs around for DBus's service



commit 2f3af8025d1d92b19b1d5ac62e168444775f4110
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Sep 15 12:56:37 2010 +0200

    libtracker-miner, miners/fs: Don't keep DBusGProxy instancs around for DBus's service

 src/libtracker-miner/tracker-dbus.c |    8 ++------
 src/miners/fs/tracker-dbus.c        |   21 ++++++++++++++-------
 2 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-dbus.c b/src/libtracker-miner/tracker-dbus.c
index 184a7ee..156d97b 100644
--- a/src/libtracker-miner/tracker-dbus.c
+++ b/src/libtracker-miner/tracker-dbus.c
@@ -30,7 +30,6 @@
 
 typedef struct {
 	DBusGConnection *connection;
-	DBusGProxy *gproxy;
 	GHashTable *name_monitors;
 } DBusData;
 
@@ -171,10 +170,6 @@ dbus_data_destroy (gpointer data)
 
 	dd = data;
 
-	if (dd->gproxy) {
-		g_object_unref (dd->gproxy);
-	}
-
 	if (dd->connection) {
 		dbus_g_connection_unref (dd->connection);
 	}
@@ -243,12 +238,13 @@ dbus_data_create (TrackerMiner          *miner,
 	/* Connection object is a shared one, so we need to keep our own
 	 * reference to it */
 	data->connection = dbus_g_connection_ref (connection);
-	data->gproxy = gproxy;
 	data->name_monitors = g_hash_table_new_full (g_str_hash,
 	                                             g_str_equal,
 	                                             (GDestroyNotify) g_free,
 	                                             NULL);
 
+	g_object_unref (gproxy);
+
 	return data;
 }
 
diff --git a/src/miners/fs/tracker-dbus.c b/src/miners/fs/tracker-dbus.c
index 7ae29f8..382f8ef 100644
--- a/src/miners/fs/tracker-dbus.c
+++ b/src/miners/fs/tracker-dbus.c
@@ -26,7 +26,6 @@
 #include "tracker-miner-files-index-glue.h"
 
 static DBusGConnection *connection;
-static DBusGProxy      *gproxy;
 static GSList          *objects;
 
 static gboolean
@@ -81,6 +80,7 @@ static gboolean
 dbus_register_names (void)
 {
 	GError *error = NULL;
+	DBusGProxy *gproxy;
 
 	if (connection) {
 		g_critical ("The DBusGConnection is already set, have we already initialized?");
@@ -111,9 +111,12 @@ dbus_register_names (void)
 
 	/* Register the service name for org.freedesktop.Tracker1.Miner.Files.Index */
 	if (!dbus_register_service (gproxy, TRACKER_MINER_FILES_INDEX_SERVICE)) {
+		g_object_unref (gproxy);
 		return FALSE;
 	}
 
+	g_object_unref (gproxy);
+
 	return TRUE;
 }
 
@@ -142,20 +145,17 @@ tracker_dbus_shutdown (void)
 		objects = NULL;
 	}
 
-	if (gproxy) {
-		g_object_unref (gproxy);
-		gproxy = NULL;
-	}
-
 	connection = NULL;
 }
 
 gboolean
 tracker_dbus_register_objects (gpointer object)
 {
+	DBusGProxy *gproxy;
+
 	g_return_val_if_fail (TRACKER_IS_MINER_FILES_INDEX (object), FALSE);
 
-	if (!connection || !gproxy) {
+	if (!connection) {
 		g_critical ("D-Bus support must be initialized before registering objects!");
 		return FALSE;
 	}
@@ -166,6 +166,11 @@ tracker_dbus_register_objects (gpointer object)
 		return FALSE;
 	}
 
+	gproxy = dbus_g_proxy_new_for_name (connection,
+	                                    DBUS_SERVICE_DBUS,
+	                                    DBUS_PATH_DBUS,
+	                                    DBUS_INTERFACE_DBUS);
+
 	dbus_register_object (connection,
 	                      gproxy,
 	                      G_OBJECT (object),
@@ -173,6 +178,8 @@ tracker_dbus_register_objects (gpointer object)
 	                      TRACKER_MINER_FILES_INDEX_PATH);
 	objects = g_slist_prepend (objects, object);
 
+	g_object_unref (gproxy);
+
 	return TRUE;
 }
 



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