[gnome-bluetooth/gnome-2-28] Only clean up the rfkill monitoring if it has actually been set up



commit 2619a0a396baa2c3b9d440f07acc316e1e32fc3e
Author: Joshua Lock <josh linux intel com>
Date:   Tue Oct 13 21:35:03 2009 +0100

    Only clean up the rfkill monitoring if it has actually been set up
    
    If the rfkill monitoring is never set up the cleanup code results in
    GLib-Critical assertion messages.
    Therefore only clean up the monitoring if the watch_id is greater than zero
    
    https://bugzilla.gnome.org/show_bug.cgi?id=598329

 lib/bluetooth-killswitch.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/lib/bluetooth-killswitch.c b/lib/bluetooth-killswitch.c
index 4d3d961..f4927a1 100644
--- a/lib/bluetooth-killswitch.c
+++ b/lib/bluetooth-killswitch.c
@@ -325,9 +325,12 @@ bluetooth_killswitch_finalize (GObject *object)
 	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (object);
 
 	/* cleanup monitoring */
-	g_source_remove(priv->watch_id);
-	g_io_channel_shutdown(priv->channel, FALSE, NULL);
-	g_io_channel_unref(priv->channel);
+	if (priv->watch_id > 0) {
+		g_source_remove (priv->watch_id);
+		priv->watch_id = 0;
+		g_io_channel_shutdown (priv->channel, FALSE, NULL);
+		g_io_channel_unref (priv->channel);
+	}
 	close(priv->fd);
 
 	g_list_foreach (priv->killswitches, (GFunc) g_free, NULL);



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