tracker r3170 - in trunk: . src/libtracker-common



Author: carlosg
Date: Fri Apr  3 13:27:38 2009
New Revision: 3170
URL: http://svn.gnome.org/viewvc/tracker?rev=3170&view=rev

Log:
2009-04-03  Carlos Garnacho  <carlos imendio com>

        * src/libtracker-common/tracker-hal.c (tracker_hal_init)
        (tracker_hal_finalize): Keep a pointer to the DBusConnection in order
        to unref it. Also, shut the libhal context down before destroying it,
        Fixes NB#107570.

Modified:
   trunk/ChangeLog
   trunk/src/libtracker-common/tracker-hal.c

Modified: trunk/src/libtracker-common/tracker-hal.c
==============================================================================
--- trunk/src/libtracker-common/tracker-hal.c	(original)
+++ trunk/src/libtracker-common/tracker-hal.c	Fri Apr  3 13:27:38 2009
@@ -47,6 +47,7 @@
 
 typedef struct {
 	LibHalContext *context;
+	DBusConnection *connection;
 
 	GHashTable    *all_devices;
 	GHashTable    *mounted_devices;
@@ -171,7 +172,6 @@
 {
 	TrackerHalPriv *priv;
 	DBusError	error;
-	DBusConnection *connection;
 
 	g_message ("Initializing HAL...");
 
@@ -198,7 +198,7 @@
 
 	dbus_error_init (&error);
 
-	connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+	priv->connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
 	if (dbus_error_is_set (&error)) {
 		g_critical ("Could not get the system DBus connection, %s",
 			    error.message);
@@ -206,8 +206,8 @@
 		return;
 	}
 
-	dbus_connection_set_exit_on_disconnect (connection, FALSE);
-	dbus_connection_setup_with_g_main (connection, NULL);
+	dbus_connection_set_exit_on_disconnect (priv->connection, FALSE);
+	dbus_connection_setup_with_g_main (priv->connection, NULL);
 
 	priv->context = libhal_ctx_new ();
 
@@ -217,7 +217,7 @@
 	}
 
 	libhal_ctx_set_user_data (priv->context, hal);
-	libhal_ctx_set_dbus_connection (priv->context, connection);
+	libhal_ctx_set_dbus_connection (priv->context, priv->connection);
 
 	if (!libhal_ctx_init (priv->context, &error)) {
 		if (dbus_error_is_set (&error)) {
@@ -283,10 +283,15 @@
 	g_free (priv->ac_adapter_udi);
 
 	if (priv->context) {
+		libhal_ctx_shutdown (priv->context, NULL);
 		libhal_ctx_set_user_data (priv->context, NULL);
 		libhal_ctx_free (priv->context);
 	}
 
+	if (priv->connection) {
+		dbus_connection_unref (priv->connection);
+	}
+
 	(G_OBJECT_CLASS (tracker_hal_parent_class)->finalize) (object);
 }
 



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