device: Attach sources to correct main context
We were attaching the sources to the default main context. Instead, we should be attaching them to the current tasks main context (or, failing that, the current thread local main context).
This commit is contained in:
parent
1ca56adff5
commit
b9df7a4e70
2 changed files with 11 additions and 3 deletions
|
@ -113,7 +113,8 @@ fp_device_cancelled_cb (GCancellable *cancellable, FpDevice *self)
|
|||
fp_device_cancel_in_idle_cb,
|
||||
self,
|
||||
NULL);
|
||||
g_source_attach (priv->current_idle_cancel_source, NULL);
|
||||
g_source_attach (priv->current_idle_cancel_source,
|
||||
g_task_get_context (priv->current_task));
|
||||
g_source_unref (priv->current_idle_cancel_source);
|
||||
}
|
||||
|
||||
|
|
|
@ -334,12 +334,18 @@ fpi_device_add_timeout (FpDevice *device,
|
|||
{
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (device);
|
||||
FpDeviceTimeoutSource *source;
|
||||
GMainContext *context;
|
||||
|
||||
source = (FpDeviceTimeoutSource *) g_source_new (&timeout_funcs,
|
||||
sizeof (FpDeviceTimeoutSource));
|
||||
source->device = device;
|
||||
|
||||
g_source_attach (&source->source, NULL);
|
||||
if (priv->current_task)
|
||||
context = g_task_get_context (priv->current_task);
|
||||
else
|
||||
context = g_main_context_get_thread_default ();
|
||||
|
||||
g_source_attach (&source->source, context);
|
||||
g_source_set_callback (&source->source, (GSourceFunc) func, user_data, destroy_notify);
|
||||
g_source_set_ready_time (&source->source,
|
||||
g_source_get_time (&source->source) + interval * (guint64) 1000);
|
||||
|
@ -930,7 +936,8 @@ fpi_device_return_task_in_idle (FpDevice *device,
|
|||
data,
|
||||
(GDestroyNotify) fpi_device_task_return_data_free);
|
||||
|
||||
g_source_attach (priv->current_task_idle_return_source, NULL);
|
||||
g_source_attach (priv->current_task_idle_return_source,
|
||||
g_task_get_context (priv->current_task));
|
||||
g_source_unref (priv->current_task_idle_return_source);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue