gobjectification: 1dce411a: Split account destruction process into f...
sadrul at pidgin.im
sadrul at pidgin.im
Tue Jul 13 18:04:03 EDT 2010
----------------------------------------------------------------------
Revision: 1dce411a6ab371e9f33e1253536ed1b688a85e86
Parent: c610605152722fa92e57831e5824058afe84f407
Author: sadrul at pidgin.im
Date: 07/13/10 17:30:05
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/1dce411a6ab371e9f33e1253536ed1b688a85e86
Changelog:
Split account destruction process into finalize and dispose.
Changes against parent c610605152722fa92e57831e5824058afe84f407
patched libpurple/account.c
patched libpurple/blist.c
-------------- next part --------------
============================================================
--- libpurple/blist.c 2e6345a091f45a9c4a82887d5290001f9c84121f
+++ libpurple/blist.c edfa81f242fc2463a0ddfe3412803854260f4534
@@ -153,18 +153,25 @@ static void
}
static void
+purple_blist_buddies_cache_remove_account(const PurpleAccount *account)
+{
+ g_hash_table_remove(PURPLE_BLIST->buddies_cache, account);
+}
+
+static void
purple_blist_buddies_cache_add_account(PurpleAccount *account)
{
GHashTable *account_buddies = g_hash_table_new_full((GHashFunc)_purple_blist_hbuddy_hash,
(GEqualFunc)_purple_blist_hbuddy_equal,
(GDestroyNotify)_purple_blist_hbuddy_free_key, NULL);
g_hash_table_insert(PURPLE_BLIST->buddies_cache, account, account_buddies);
-}
-static void
-purple_blist_buddies_cache_remove_account(const PurpleAccount *account)
-{
- g_hash_table_remove(PURPLE_BLIST->buddies_cache, account);
+ /* We want to remove this hashtable at the very last step of the account
+ * removal process. That's why we do this when the object is finalized,
+ * instead from a 'destroying' callback. */
+ g_object_weak_ref(G_OBJECT(account),
+ (GWeakNotify)purple_blist_buddies_cache_remove_account,
+ account);
}
/*********************************************************************
@@ -1498,16 +1505,9 @@ purple_blist_class_init(PurpleBuddyListC
purple_value_new(PURPLE_TYPE_INT),
purple_value_new(PURPLE_TYPE_INT));
- purple_signal_connect(purple_accounts_get_handle(), "account-created",
- handle,
- PURPLE_CALLBACK(purple_blist_buddies_cache_add_account),
- NULL);
+ purple_g_signal_connect(PURPLE_TYPE_ACCOUNT, "new",
+ G_CALLBACK(purple_blist_buddies_cache_add_account), NULL);
- purple_signal_connect(purple_accounts_get_handle(), "account-destroying",
- handle,
- PURPLE_CALLBACK(purple_blist_buddies_cache_remove_account),
- NULL);
-
/* When a new group gets created, we add it to the list. We also update the
* 'groups_cache' hashtable in the list. We update the list and the hashtable
* when the group gets removed or renamed. (TODO) */
============================================================
--- libpurple/account.c 794f06e8d2b9819d2fc890fc280d688685156aad
+++ libpurple/account.c 5a05541ae886714c64e09395f43ef58dc071727e
@@ -604,12 +604,14 @@ static void
/* GObject destructor function */
static void
-purple_account_finalize(GObject *object)
+purple_account_dispose(GObject *object)
{
PurpleAccountPrivate *priv = NULL;
GList *l;
PurpleAccount *account = PURPLE_ACCOUNT(object);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
purple_debug_info("account", "Destroying account %p\n", account);
/* Make sure we disconnect first */
@@ -621,6 +623,7 @@ purple_account_finalize(GObject *object)
*/
purple_account_clear_current_error(account);
+ /* TODO: Remove this from here, and make the conversations subsystem update itself. */
for (l = purple_get_conversations(); l != NULL; l = l->next) {
PurpleConversation *conv = (PurpleConversation *)l->data;
@@ -628,18 +631,6 @@ purple_account_finalize(GObject *object)
purple_conversation_set_account(conv, NULL);
}
- priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
-
- g_free(priv->username);
- g_free(priv->alias);
- g_free(priv->password);
- g_free(priv->user_info);
- g_free(priv->buddy_icon_path);
- g_free(priv->protocol_id);
-
- g_hash_table_destroy(priv->settings);
- g_hash_table_destroy(priv->ui_settings);
-
purple_account_set_status_types(account, NULL);
purple_presence_destroy(priv->presence);
@@ -654,9 +645,30 @@ purple_account_finalize(GObject *object)
}
PURPLE_DBUS_UNREGISTER_POINTER(account);
- parent_class->finalize(object);
+ parent_class->dispose(object);
}
+static void
+purple_account_finalize(GObject *obj)
+{
+ PurpleAccountPrivate *priv = NULL;
+ PurpleAccount *account = PURPLE_ACCOUNT(obj);
+
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
+ g_free(priv->username);
+ g_free(priv->alias);
+ g_free(priv->password);
+ g_free(priv->user_info);
+ g_free(priv->buddy_icon_path);
+ g_free(priv->protocol_id);
+
+ g_hash_table_destroy(priv->settings);
+ g_hash_table_destroy(priv->ui_settings);
+
+ parent_class->finalize(obj);
+}
+
/* Class initializer function */
static void purple_account_class_init(PurpleAccountClass *klass)
{
@@ -664,6 +676,7 @@ static void purple_account_class_init(Pu
parent_class = g_type_class_peek_parent(klass);
+ obj_class->dispose = purple_account_dispose;
obj_class->finalize = purple_account_finalize;
/* Setup properties */
More information about the Commits
mailing list