[epiphany] Disconnect dbus callbacks when disposing of the monitor.



commit 76d1c18d5cd267a97ef2a33950cb6b837032bd80
Author: Tom Parker <palfrey tevp net>
Date:   Wed Nov 18 14:44:09 2009 +0200

    Disconnect dbus callbacks when disposing of the monitor.
    
    Fixes a crash in some situations, bug #572326
    
    Signed-off-by: Xan Lopez <xan gnome org>

 src/ephy-net-monitor.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/ephy-net-monitor.c b/src/ephy-net-monitor.c
index 69f8be7..3107ad2 100644
--- a/src/ephy-net-monitor.c
+++ b/src/ephy-net-monitor.c
@@ -107,7 +107,7 @@ ephy_net_monitor_check_network (EphyNetMonitor *monitor)
 	DBusMessage *message;
 	DBusPendingCall* reply;
 
-	if (priv->bus == NULL) return;
+	g_return_if_fail (priv == NULL || priv->bus == NULL);
 
 	LOG ("EphyNetMonitor checking network");
 
@@ -199,6 +199,23 @@ ephy_net_monitor_attach_to_dbus (EphyNetMonitor *monitor)
 }
 
 static void
+ephy_net_monitor_detach_from_dbus (EphyNetMonitor *monitor)
+{
+	EphyNetMonitorPrivate *priv = monitor->priv;
+	
+	LOG ("EphyNetMonitor is trying to detach from SYSTEM bus");
+
+	if (priv->bus != NULL)
+	{
+		dbus_connection_remove_filter (priv->bus, 
+					       filter_func, 
+					       monitor);
+		priv->bus = NULL;
+	}
+}
+
+
+static void
 connect_to_system_bus_cb (EphyDbus *dbus,
 			  EphyDbusBus kind,
 			  EphyNetMonitor *monitor)
@@ -216,14 +233,12 @@ disconnect_from_system_bus_cb (EphyDbus *dbus,
 			       EphyDbusBus kind,
 			       EphyNetMonitor *monitor)
 {
-	EphyNetMonitorPrivate *priv = monitor->priv;
-
 	if (kind == EPHY_DBUS_SYSTEM)
 	{
 		LOG ("EphyNetMonitor disconnected from SYSTEM bus");
 
 		/* no bus anymore */
-		priv->bus = NULL;
+		ephy_net_monitor_detach_from_dbus (monitor);
 	}
 }
 
@@ -258,6 +273,7 @@ ephy_net_monitor_shutdown (EphyNetMonitor *monitor)
 
 	dbus = ephy_dbus_get_default ();
 			
+	ephy_net_monitor_detach_from_dbus (monitor);
 	g_signal_handlers_disconnect_by_func
 		(dbus, G_CALLBACK (connect_to_system_bus_cb), monitor);
 	g_signal_handlers_disconnect_by_func



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