summaryrefslogtreecommitdiff
path: root/src/devices/wifi
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/wifi')
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index 9642e0955a..cec3887712 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -71,6 +71,7 @@ enum {
struct _NMDeviceOlpcMeshPrivate {
NMDevice *companion;
+ NMManager *manager;
gboolean stage1_waiting;
};
@@ -391,7 +392,7 @@ find_companion (NMDeviceOlpcMesh *self)
nm_device_add_pending_action (NM_DEVICE (self), "waiting for companion", TRUE);
/* Try to find the companion if it's already known to the NMManager */
- for (list = nm_manager_get_devices (nm_manager_get ()); list ; list = g_slist_next (list)) {
+ for (list = nm_manager_get_devices (priv->manager); list ; list = g_slist_next (list)) {
if (check_companion (self, NM_DEVICE (list->data))) {
nm_device_queue_recheck_available (NM_DEVICE (self),
NM_DEVICE_STATE_REASON_NONE,
@@ -438,6 +439,7 @@ constructor (GType type,
GObject *object;
GObjectClass *klass;
NMDeviceOlpcMesh *self;
+ NMDeviceOlpcMeshPrivate *priv;
NMDeviceWifiCapabilities caps;
klass = G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class);
@@ -446,6 +448,7 @@ constructor (GType type,
return NULL;
self = NM_DEVICE_OLPC_MESH (object);
+ priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &caps)) {
_LOGW (LOGD_HW | LOGD_OLPC, "failed to initialize WiFi driver");
@@ -453,8 +456,10 @@ constructor (GType type,
return NULL;
}
- g_signal_connect (nm_manager_get (), "device-added", G_CALLBACK (device_added_cb), self);
- g_signal_connect (nm_manager_get (), "device-removed", G_CALLBACK (device_removed_cb), self);
+ priv->manager = g_object_ref (nm_manager_get ());
+
+ g_signal_connect (priv->manager, "device-added", G_CALLBACK (device_added_cb), self);
+ g_signal_connect (priv->manager, "device-removed", G_CALLBACK (device_removed_cb), self);
/* shorter timeout for mesh connectivity */
nm_device_set_dhcp_timeout (NM_DEVICE (self), 20);
@@ -496,10 +501,15 @@ static void
dispose (GObject *object)
{
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (object);
+ NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
companion_cleanup (self);
- g_signal_handlers_disconnect_by_func (nm_manager_get (), G_CALLBACK (device_added_cb), self);
- g_signal_handlers_disconnect_by_func (nm_manager_get (), G_CALLBACK (device_removed_cb), self);
+
+ if (priv->manager) {
+ g_signal_handlers_disconnect_by_func (priv->manager, G_CALLBACK (device_added_cb), self);
+ g_signal_handlers_disconnect_by_func (priv->manager, G_CALLBACK (device_removed_cb), self);
+ g_clear_object (&priv->manager);
+ }
G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->dispose (object);
}