[Telepathy-commits] [telepathy-mission-control/master] Keep the channel alive in the online requests queue
Alberto Mardegan
alberto.mardegan at nokia.com
Thu Jan 8 06:49:13 PST 2009
When putting the channel into the online_requests queue, reference it; the
unreference will be done when the callback will be invoked.
This is needed to avoid a crash that can happen if the channel is aborted while
we are waiting for the connection; it's probably not triggered now, but it will
happen when channel request cancellation is implemented.
---
src/mcd-account-requests.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/mcd-account-requests.c b/src/mcd-account-requests.c
index 8162b24..668d51e 100644
--- a/src/mcd-account-requests.c
+++ b/src/mcd-account-requests.c
@@ -50,8 +50,7 @@ online_request_cb (McdAccount *account, gpointer userdata, const GError *error)
{
g_warning ("%s: got error: %s", G_STRFUNC, error->message);
_mcd_channel_set_error (channel, g_error_copy (error));
- /* no unref here, as this will invoke our handler which will
- * unreference the channel */
+ g_object_unref (channel);
return;
}
g_debug ("%s called", G_STRFUNC);
@@ -60,9 +59,8 @@ online_request_cb (McdAccount *account, gpointer userdata, const GError *error)
g_return_if_fail (mcd_connection_get_connection_status (connection)
== TP_CONNECTION_STATUS_CONNECTED);
- /* the connection will take ownership of the channel, so let's keep a
- * reference to it to make sure it's not destroyed while we are using it */
- g_object_ref (channel);
+ /* the connection will take ownership of the channel, so the reference we
+ * are holding is passed to it */
mcd_connection_request_channel (connection, channel);
}
@@ -128,6 +126,13 @@ create_request (McdAccount *account, GHashTable *properties,
/* no unref here, as this will invoke our handler which will
* unreference the channel */
}
+ else
+ {
+ /* the channel must be kept alive until online_request_cb is called;
+ * this reference will be removed in that callback */
+ g_object_ref (channel);
+ }
+
return channel;
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list