mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 23:50:10 +01:00
libnm/tests: unsubscribe signal handler during test_activate_virtual()
libnm is gonna change, where it would still emit signals when the
instance gets destructed. In particular, when the device gets removed
from the NMClient cache, the references to other objects would be
cleared (and consequently property changed signals emitted).
This will cause a test failure, because the signal was not unsubscribed:
test:ERROR:libnm/tests/test-nm-client.c:694:device_ac_changed_cb: assertion failed: (nm_device_get_active_connection (NM_DEVICE (device)) != NULL)
This commit is contained in:
parent
f21b8781ed
commit
feea4222ef
1 changed files with 13 additions and 3 deletions
|
|
@ -606,6 +606,9 @@ typedef struct {
|
|||
NMActiveConnection *ac;
|
||||
|
||||
int remaining;
|
||||
|
||||
NMDevice *device;
|
||||
gulong ac_signal_id;
|
||||
} TestACInfo;
|
||||
|
||||
static void
|
||||
|
|
@ -768,9 +771,12 @@ client_devices_changed_cb (GObject *client,
|
|||
g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0.1");
|
||||
|
||||
if (!nm_device_get_active_connection (device)) {
|
||||
g_assert (info->ac_signal_id == 0);
|
||||
info->remaining++;
|
||||
g_signal_connect (device, "notify::" NM_DEVICE_ACTIVE_CONNECTION,
|
||||
G_CALLBACK (device_ac_changed_cb), info);
|
||||
info->device = device;
|
||||
g_object_add_weak_pointer (G_OBJECT (device), (gpointer *) &info->device);
|
||||
info->ac_signal_id = g_signal_connect (device, "notify::" NM_DEVICE_ACTIVE_CONNECTION,
|
||||
G_CALLBACK (device_ac_changed_cb), info);
|
||||
}
|
||||
|
||||
info->remaining--;
|
||||
|
|
@ -872,8 +878,12 @@ test_activate_virtual (void)
|
|||
g_signal_handlers_disconnect_by_func (client, client_devices_changed_cb, &info);
|
||||
|
||||
g_assert (info.ac != NULL);
|
||||
g_clear_object (&info.ac);
|
||||
|
||||
g_object_unref (info.ac);
|
||||
if (info.device) {
|
||||
g_object_remove_weak_pointer (G_OBJECT (info.device), (gpointer *) &info.device);
|
||||
nm_clear_g_signal_handler (info.device, &info.ac_signal_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue