mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 19:10:09 +01:00
wifi-olpc: refactor NMDeviceOlpcMesh to hold pointer to NMManager
Objects that register to a signal of a singleton should own a reference
to the singleton to ensure the proper lifetime of the singleton upon shutdown.
(cherry picked from commit e2e22eb574)
This commit is contained in:
parent
2f012d80d7
commit
75131ed654
1 changed files with 15 additions and 5 deletions
|
|
@ -77,6 +77,7 @@ enum {
|
|||
|
||||
struct _NMDeviceOlpcMeshPrivate {
|
||||
NMDevice *companion;
|
||||
NMManager *manager;
|
||||
gboolean stage1_waiting;
|
||||
};
|
||||
|
||||
|
|
@ -397,7 +398,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,
|
||||
|
|
@ -445,6 +446,7 @@ constructor (GType type,
|
|||
GObject *object;
|
||||
GObjectClass *klass;
|
||||
NMDeviceOlpcMesh *self;
|
||||
NMDeviceOlpcMeshPrivate *priv;
|
||||
NMDeviceWifiCapabilities caps;
|
||||
|
||||
klass = G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class);
|
||||
|
|
@ -453,6 +455,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");
|
||||
|
|
@ -460,8 +463,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);
|
||||
|
|
@ -506,10 +511,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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue