Commit da348185 authored by Zeeshan Ali's avatar Zeeshan Ali

modem-source: Don't assume synchronous cancellation

g_cancellable_cancel() isn't expected to synchronously cancel the async
operations and hence in the callbacks of async API, we shouldn't assume
the passed object (as user_data) to be there before successfully
finishing the async call (and thus ensuring it was not cancelled).
parent bc975c21
......@@ -120,18 +120,21 @@ on_modem_location_setup (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GClueModemSourcePrivate *priv = GCLUE_MODEM_SOURCE (user_data)->priv;
GClueModemSourcePrivate *priv;
GError *error = NULL;
if (!mm_modem_location_setup_finish (priv->modem_location, res, &error)) {
if (!mm_modem_location_setup_finish (MM_MODEM_LOCATION (source_object),
res,
&error)) {
g_warning ("Failed to setup modem: %s", error->message);
g_error_free (error);
return;
}
priv = GCLUE_MODEM_SOURCE (user_data)->priv;
g_debug ("Modem '%s' setup.", mm_object_get_path (priv->mm_object));
on_location_changed (G_OBJECT (priv->modem_location), NULL, user_data);
on_location_changed (source_object, NULL, user_data);
}
static void
......@@ -139,24 +142,25 @@ on_modem_enabled (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GClueModemSource *source= GCLUE_MODEM_SOURCE (user_data);
GClueModemSourcePrivate *priv = source->priv;
GClueModemSourcePrivate *priv;
MMModemLocationSource caps;
GError *error = NULL;
if (!mm_modem_enable_finish (priv->modem, res, &error)) {
if (error->code == MM_CORE_ERROR_IN_PROGRESS)
if (!mm_modem_enable_finish (MM_MODEM (source_object), res, &error)) {
if (error->code == MM_CORE_ERROR_IN_PROGRESS) {
/* Seems another source instance is already on it */
priv = GCLUE_MODEM_SOURCE (user_data)->priv;
g_signal_connect (G_OBJECT (priv->modem_location),
"notify::location",
G_CALLBACK (on_location_changed),
user_data);
else
} else
g_warning ("Failed to enable modem: %s", error->message);
g_error_free (error);
return;
}
priv = GCLUE_MODEM_SOURCE (user_data)->priv;
g_debug ("modem '%s' enabled.", mm_object_get_path (priv->mm_object));
g_signal_connect (G_OBJECT (priv->modem_location),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment