[tracker/tracker-0.10] tracker-writeback: Make dispatcher's finalize cope with incomplete init



commit 72fa7a8752333d8ed1b724d94ec2eaf3e320fa43
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Mar 1 12:41:37 2011 +0100

    tracker-writeback: Make dispatcher's finalize cope with incomplete init

 .../tracker-writeback-dispatcher.c                 |   22 ++++++++++++-------
 1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback-dispatcher.c b/src/tracker-writeback/tracker-writeback-dispatcher.c
index 065a1e4..f3f89c3 100644
--- a/src/tracker-writeback/tracker-writeback-dispatcher.c
+++ b/src/tracker-writeback/tracker-writeback-dispatcher.c
@@ -45,6 +45,7 @@
 typedef struct {
 	GMainContext *context;
 	DBusConnection *connection;
+	gboolean good_init;
 } TrackerWritebackDispatcherPrivate;
 
 enum {
@@ -264,10 +265,12 @@ tracker_writeback_dispatcher_initable_init (GInitable     *initable,
 	                                    &internal_error);
 
 	if (internal_error) {
+		priv->good_init = FALSE;
 		g_propagate_error (error, internal_error);
 		return FALSE;
 	} else {
 		priv->connection = connection;
+		priv->good_init = TRUE;
 	}
 
 	return TRUE;
@@ -319,17 +322,20 @@ tracker_writeback_dispatcher_finalize (GObject *object)
 	DBusError error;
 
 	priv = TRACKER_WRITEBACK_DISPATCHER_GET_PRIVATE (object);
-	dbus_error_init (&error);
 
-	dbus_bus_remove_match (priv->connection, DBUS_MATCH_STR, &error);
+	if (priv->good_init) {
+		dbus_error_init (&error);
 
-	if (dbus_error_is_set (&error)) {
-		g_critical ("Could not remove match rules, %s", error.message);
-		dbus_error_free (&error);
-	}
+		dbus_bus_remove_match (priv->connection, DBUS_MATCH_STR, &error);
 
-	dbus_connection_remove_filter (priv->connection, message_filter, object);
-	dbus_connection_unref (priv->connection);
+		if (dbus_error_is_set (&error)) {
+			g_critical ("Could not remove match rules, %s", error.message);
+			dbus_error_free (&error);
+		}
+
+		dbus_connection_remove_filter (priv->connection, message_filter, object);
+		dbus_connection_unref (priv->connection);
+	}
 
 	G_OBJECT_CLASS (tracker_writeback_dispatcher_parent_class)->finalize (object);
 }



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