From d37dbaca2ad66beeeae6e52db1293a3e8a60b7d7 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 16 May 2011 18:58:43 +0200 Subject: core: ensure ERROR_REMOVED error is used in MMCallbackInfo when detecting modem removal --- src/mm-callback-info.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mm-callback-info.c b/src/mm-callback-info.c index aa1f13ab..a230e690 100644 --- a/src/mm-callback-info.c +++ b/src/mm-callback-info.c @@ -47,19 +47,24 @@ invoke_mm_modem_string_fn (MMCallbackInfo *info) info->error, info->user_data); } - static void modem_destroyed_cb (gpointer data, GObject *destroyed) { MMCallbackInfo *info = data; + /* Reset modem pointer, so that callback know that they shouldn't do + * anything else */ info->modem = NULL; - if (!info->pending_id) { - info->error = g_error_new_literal (MM_MODEM_ERROR, - MM_MODEM_ERROR_REMOVED, - "The modem was removed."); + + /* Overwrite any possible previous error set */ + g_clear_error (&(info->error)); + info->error = g_error_new_literal (MM_MODEM_ERROR, + MM_MODEM_ERROR_REMOVED, + "The modem was removed."); + + /* Only schedule the info if not already done before */ + if (!info->pending_id) mm_callback_info_schedule (info); - } } static void -- cgit v1.2.3-70-g09d2