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



commit fae76fe0d3baaec12ecf20d3f8c5dd5c3218d0bc
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 05d6688..e700871 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]