From 4fe464f5f75bb25da5d05a9b976550732b7620b7 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 15 Apr 2017 23:26:32 +0200 Subject: core: prefer g_task_return_error_if_cancelled() than custom errors When the GCancellable is added to the GTask, we can use a single method call to check for the task being cancelled, and complete it right away if so. This patch also clears up the logic in the Novatel plugin, where the code was trying to return "TRUE" when the task was cancelled, but wouldn't work as the check-cancellable flag in the GTask is TRUE by default (i.e. when completing the GTask, if it was cancelled, a G_IO_ERROR_CANCELLED would be returned by default, regardless of any other return value set). This patch also introduces a small variation of the logic in the Cinterion plugin: instead of running SWWAN=0 before completing the async action, the command is now sent just after completion of the async action. This shouldn't be an issue, as the SWWAN result itself is ignored. --- src/mm-iface-modem-signal.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/mm-iface-modem-signal.c') diff --git a/src/mm-iface-modem-signal.c b/src/mm-iface-modem-signal.c index 9751b5d6..99096a95 100644 --- a/src/mm-iface-modem-signal.c +++ b/src/mm-iface-modem-signal.c @@ -418,11 +418,7 @@ interface_initialization_step (GTask *task) InitializationContext *ctx; /* Don't run new steps if we're cancelled */ - 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"); + if (g_task_return_error_if_cancelled (task)) { g_object_unref (task); return; } -- cgit v1.2.3-70-g09d2