[PATCH 1/4] iface-modem-location: port mm_iface_modem_location_initialize to use GTask

Aleksander Morgado aleksander at aleksander.es
Tue Jun 27 08:25:48 UTC 2017


On Tue, Jun 27, 2017 at 7:53 AM, Ben Chan <benchan at chromium.org> wrote:
>      /* Don't run new steps if we're cancelled */
> -    if (initialization_context_complete_and_free_if_cancelled (ctx))
> +    if (g_cancellable_is_cancelled (g_task_get_cancellable (task))) {
> +        g_task_return_new_error (task,
> +                                 MM_CORE_ERROR,
> +                                 MM_CORE_ERROR_CANCELLED,
> +                                 "Interface initialization cancelled");
> +        g_object_unref (task);
>          return;
> +    }
> +

I believe we should start using this instead:

if (g_task_return_error_if_cancelled (task)) {
    g_object_unref (task);
    return;
}

Note that the GError set is a G_IO_ERROR/G_IO_ERROR_CANCELLED (instead
of MM_CORE_ERROR/MM_CORE_ERROR_CANCELLED) but that is probably not a
big deal, unless the caller does a g_error_matches() which wouldn't be
very usual for a cancelled error.

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list