From 511d456006c90eebf6fcda2ae962d76cf78a89b1 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Thu, 22 Apr 2021 16:37:18 +0200 Subject: [PATCH] context: Use g_signal_connect_object for removal handling Technically the API user might not keep the FpContext around after getting the device object. Really bad idea, but we shouldn't rely on that. --- libfprint/fp-context.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libfprint/fp-context.c b/libfprint/fp-context.c index ea99e06..2b40d73 100644 --- a/libfprint/fp-context.c +++ b/libfprint/fp-context.c @@ -147,9 +147,16 @@ device_removed_cb (FpContext *context, FpDevice *device) /* Wait for device close if the device is currently still open. */ if (open) - g_signal_connect_swapped (device, "notify::open", (GCallback) device_remove_on_notify_open_cb, context); + { + g_signal_connect_object (device, "notify::open", + (GCallback) device_remove_on_notify_open_cb, + context, + G_CONNECT_SWAPPED); + } else - remove_device (context, device); + { + remove_device (context, device); + } } static void @@ -177,7 +184,10 @@ async_device_init_done_cb (GObject *source_object, GAsyncResult *res, gpointer u g_ptr_array_add (priv->devices, device); - g_signal_connect_swapped (device, "removed", (GCallback) device_removed_cb, context); + g_signal_connect_object (device, "removed", + (GCallback) device_removed_cb, + context, + G_CONNECT_SWAPPED); g_signal_emit (context, signals[DEVICE_ADDED_SIGNAL], 0, device); }