context: Ensure that context won't include a removed device at signal time

If a device has been removed from context, at that point we it should
not be returned by fp_context_get_devices().
This commit is contained in:
Marco Trevisan (Treviño) 2023-06-22 22:43:27 +02:00 committed by Marco Trevisan
parent da9849613e
commit d66e9470d8
2 changed files with 5 additions and 1 deletions

View file

@ -96,8 +96,10 @@ remove_device (FpContext *context,
g_return_if_fail (g_ptr_array_find (priv->devices, device, &idx));
g_signal_emit (context, signals[DEVICE_REMOVED_SIGNAL], 0, device);
g_object_ref (device);
g_ptr_array_remove_index_fast (priv->devices, idx);
g_signal_emit (context, signals[DEVICE_REMOVED_SIGNAL], 0, device);
g_clear_object (&device);
}
static void

View file

@ -115,6 +115,8 @@ context_device_removed_cb (FpContext *ctx, FpDevice *device, FptContext *tctx)
/* "device-removed" on context is always after "removed" on device */
g_assert_cmpint (GPOINTER_TO_INT (tctx->user_data), ==, DEV_REMOVED_CB);
tctx->user_data = GINT_TO_POINTER (CTX_DEVICE_REMOVED_CB);
g_assert_false (g_ptr_array_find (fp_context_get_devices (tctx->fp_context), device, NULL));
}
static void