[libgdata] core: Keep GDataClientLoginAuthorizer alive while notifying property changes
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] core: Keep GDataClientLoginAuthorizer alive while notifying property changes
- Date: Mon, 20 Jun 2011 20:38:34 +0000 (UTC)
commit 3b62d2d1f24e56ee8a60a99a371f830a54a7a958
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Jun 20 21:34:38 2011 +0100
core: Keep GDataClientLoginAuthorizer alive while notifying property changes
It's possible for the GDataClientLoginAuthorizer to be finalised after
scheduling property notifications to happen in an idle function, but before
the idle function is called. This would cause crashes, so we hold a reference
to the authorizer while waiting for the idle function to be called.
gdata/gdata-client-login-authorizer.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gdata/gdata-client-login-authorizer.c b/gdata/gdata-client-login-authorizer.c
index 6e1722a..ab7f66c 100644
--- a/gdata/gdata-client-login-authorizer.c
+++ b/gdata/gdata-client-login-authorizer.c
@@ -489,7 +489,8 @@ gdata_client_login_authorizer_new_for_authorization_domains (const gchar *client
return authorizer;
}
-/* Called in the main thread to notify of changes to the username and password properties from the authentication thread */
+/* Called in the main thread to notify of changes to the username and password properties from the authentication thread. It swallows a reference
+ * the authoriser. */
static gboolean
notify_authentication_details_cb (GDataClientLoginAuthorizer *self)
{
@@ -500,6 +501,8 @@ notify_authentication_details_cb (GDataClientLoginAuthorizer *self)
g_object_notify (authorizer, "password");
g_object_thaw_notify (authorizer);
+ g_object_unref (self);
+
/* Only execute once */
return FALSE;
}
@@ -530,9 +533,9 @@ set_authentication_details (GDataClientLoginAuthorizer *self, const gchar *usern
* â notifications will always be emitted before gdata_client_login_authorizer_authenticate() returns; and
* â notifications will always be emitted in the main thread for calls to gdata_client_login_authorizer_authenticate_async(). */
if (is_async == TRUE) {
- g_idle_add ((GSourceFunc) notify_authentication_details_cb, self);
+ g_idle_add ((GSourceFunc) notify_authentication_details_cb, g_object_ref (self));
} else {
- notify_authentication_details_cb (self);
+ notify_authentication_details_cb (g_object_ref (self));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]