context: Factorize duplicated code

This commit is contained in:
Marco Trevisan (Treviño) 2020-04-24 20:00:28 +02:00
parent 5de49b33e6
commit bc3f622b2a

View file

@ -94,22 +94,21 @@ async_device_init_done_cb (GObject *source_object, GAsyncResult *res, gpointer u
FpContext *context; FpContext *context;
FpContextPrivate *priv; FpContextPrivate *priv;
device = (FpDevice *) g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); device = FP_DEVICE (g_async_initable_new_finish (G_ASYNC_INITABLE (source_object),
if (!device) res, &error));
{ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return;
return;
context = FP_CONTEXT (user_data);
priv = fp_context_get_instance_private (context);
priv->pending_devices--;
g_message ("Ignoring device due to initialization error: %s", error->message);
return;
}
context = FP_CONTEXT (user_data); context = FP_CONTEXT (user_data);
priv = fp_context_get_instance_private (context); priv = fp_context_get_instance_private (context);
priv->pending_devices--; priv->pending_devices--;
if (error)
{
g_message ("Ignoring device due to initialization error: %s", error->message);
return;
}
g_ptr_array_add (priv->devices, device); g_ptr_array_add (priv->devices, device);
g_signal_emit (context, signals[DEVICE_ADDED_SIGNAL], 0, device); g_signal_emit (context, signals[DEVICE_ADDED_SIGNAL], 0, device);
} }