usb-transfer: Use fpi_device_add_timeout instead of g_idle_add

g_idle_add attaches to the default main context, but the rest of
libfprint is using the thread local main context. Switch to use the
internal fpi_device_add_timeout API for the workaround in order to
not rely on the default main context.
This commit is contained in:
Benjamin Berg 2021-04-22 18:51:20 +02:00
parent d683b271d4
commit 1ca56adff5

View file

@ -354,9 +354,10 @@ transfer_finish_cb (GObject *source_object, GAsyncResult *res, gpointer user_dat
fpi_usb_transfer_unref (transfer);
}
static gboolean
transfer_cancel_cb (FpiUsbTransfer *transfer)
static void
transfer_cancel_cb (FpDevice *device, gpointer user_data)
{
FpiUsbTransfer *transfer = user_data;
GError *error;
FpiUsbTransferCallback callback;
@ -369,8 +370,6 @@ transfer_cancel_cb (FpiUsbTransfer *transfer)
callback (transfer, transfer->device, transfer->user_data, error);
fpi_usb_transfer_unref (transfer);
return G_SOURCE_REMOVE;
}
/**
@ -413,7 +412,8 @@ fpi_usb_transfer_submit (FpiUsbTransfer *transfer,
*/
if (cancellable && g_cancellable_is_cancelled (cancellable))
{
g_idle_add ((GSourceFunc) transfer_cancel_cb, transfer);
fpi_device_add_timeout (transfer->device, 0,
transfer_cancel_cb, transfer, NULL);
return;
}