summary refs log tree commit diff
path: root/src/devices/bluetooth/nm-bluez-device.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2016-03-01 16:55:22 +0100
committerMichael Biebl <biebl@debian.org>2016-03-01 16:55:22 +0100
commitc2de0d98ba39e0a1a970d066fd19be786092f376 (patch)
tree3838363c06a6019db6cf1f882ea34ebded63c38b /src/devices/bluetooth/nm-bluez-device.c
parent494f296a3baab08522617b24b1f126d8f9a17502 (diff)
Imported Upstream version 1.1.91 upstream/1.1.91
Diffstat (limited to 'src/devices/bluetooth/nm-bluez-device.c')
-rw-r--r--src/devices/bluetooth/nm-bluez-device.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c
index b7032143..71226813 100644
--- a/src/devices/bluetooth/nm-bluez-device.c
+++ b/src/devices/bluetooth/nm-bluez-device.c
@@ -19,11 +19,10 @@
  * Copyright (C) 2013 Intel Corporation.
  */
 
-#include "config.h"
+#include "nm-default.h"
 
 #include <string.h>
 
-#include "nm-default.h"
 #include "nm-core-internal.h"
 
 #include "nm-bt-error.h"
@@ -1014,7 +1013,7 @@ nm_bluez_device_new (const char *path,
 	const char *interface_name = NULL;
 
 	g_return_val_if_fail (path != NULL, NULL);
-	g_return_val_if_fail (provider != NULL, NULL);
+	g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (provider), NULL);
 	g_return_val_if_fail (bluez_version == 4 || bluez_version == 5, NULL);
 
 	self = (NMBluezDevice *) g_object_new (NM_TYPE_BLUEZ_DEVICE,
@@ -1028,7 +1027,7 @@ nm_bluez_device_new (const char *path,
 	priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
 
 	priv->bluez_version = bluez_version;
-	priv->provider = provider;
+	priv->provider = g_object_ref (provider);
 	g_return_val_if_fail (bluez_version == 5 || (bluez_version == 4 && adapter_address), NULL);
 	if (adapter_address)
 		set_adapter_address (self, adapter_address);
@@ -1102,9 +1101,11 @@ dispose (GObject *object)
 	}
 #endif
 
-	g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_added, self);
-	g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_removed, self);
-	g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_updated, self);
+	if (priv->provider) {
+		g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_added, self);
+		g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_removed, self);
+		g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_updated, self);
+	}
 
 	g_slist_free_full (priv->connections, g_object_unref);
 	priv->connections = NULL;
@@ -1120,6 +1121,8 @@ dispose (GObject *object)
 		nm_settings_connection_delete (NM_SETTINGS_CONNECTION (to_delete), NULL, NULL);
 		g_object_unref (to_delete);
 	}
+
+	g_clear_object (&priv->provider);
 }
 
 static void