[PATCH] Do unrefs in dispose, not finalise for tny-camel-folder and tny-camel-store-account.



---
 ChangeLog                                   |    6 +++
 libtinymail-camel/tny-camel-folder.c        |   59 ++++++++++++++++++++-------
 libtinymail-camel/tny-camel-store-account.c |   18 ++++++--
 3 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df7a719..334f3bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-12  Rob Taylor  <rob taylor codethink co uk>
+
+	* libtinymail-camel/tny-camel-folder.c:
+	* libtinymail-camel/tny-camel-store-account.c:
+	do unrefs in dispose, not finalise for tny-camel-folder and tny-camel-store-account.
+
 2008-06-10  Sergio Villar Senin  <svillar igalia com>
 
 	* libtinymail-maemo/tny-maemo-conic-device.c:
diff --git a/libtinymail-camel/tny-camel-folder.c b/libtinymail-camel/tny-camel-folder.c
index 4fe7713..26ec7fd 100644
--- a/libtinymail-camel/tny-camel-folder.c
+++ b/libtinymail-camel/tny-camel-folder.c
@@ -6003,21 +6003,11 @@ _tny_camel_folder_freeup_observers (TnyCamelFolder *self, TnyCamelFolderPriv *pr
 }
 
 static void
-tny_camel_folder_finalize (GObject *object)
+tny_camel_folder_dispose (GObject *object)
 {
 	TnyCamelFolder *self = (TnyCamelFolder*) object;
 	TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self);
 
-
-#ifdef DEBUG
-	g_print ("Finalizing TnyCamelFolder: %s\n", 
-		priv->folder_name?priv->folder_name:"(cleared)");
-
-	if (priv->reason_to_live != 0)
-		g_print ("Finalizing TnyCamelFolder, yet TnyHeader instances "
-		"are still alive: %d\n", priv->reason_to_live);
-#endif
-
 	if (priv->store)
 		camel_object_unref (priv->store);
 
@@ -6057,10 +6047,6 @@ tny_camel_folder_finalize (GObject *object)
 		priv->folder = NULL;
 	}
 
-	if (G_LIKELY (priv->cached_name))
-		g_free (priv->cached_name);
-	priv->cached_name = NULL;
-
 	if (G_LIKELY (priv->remove_strat))
 		g_object_unref (G_OBJECT (priv->remove_strat));
 	priv->remove_strat = NULL;
@@ -6073,6 +6059,48 @@ tny_camel_folder_finalize (GObject *object)
 
 	g_static_rec_mutex_unlock (priv->folder_lock);
 
+	return;
+}
+
+
+static void
+tny_camel_folder_finalize (GObject *object)
+{
+	TnyCamelFolder *self = (TnyCamelFolder*) object;
+	TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self);
+
+
+#ifdef DEBUG
+	g_print ("Finalizing TnyCamelFolder: %s\n", 
+		priv->folder_name?priv->folder_name:"(cleared)");
+
+	if (priv->reason_to_live != 0)
+		g_print ("Finalizing TnyCamelFolder, yet TnyHeader instances "
+		"are still alive: %d\n", priv->reason_to_live);
+#endif
+
+	g_static_rec_mutex_lock (priv->folder_lock);
+	priv->dont_fkill = FALSE;
+
+	if (priv->account && TNY_IS_CAMEL_STORE_ACCOUNT (priv->account)) {
+		TnyCamelStoreAccountPriv *apriv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (priv->account);
+		g_static_rec_mutex_lock (apriv->factory_lock);
+		apriv->managed_folders = g_list_remove (apriv->managed_folders, self);
+		g_static_rec_mutex_unlock (apriv->factory_lock);
+	}
+
+	if (G_LIKELY (priv->folder))
+	{
+		camel_object_unref (priv->folder);
+		priv->folder = NULL;
+	}
+
+	if (G_LIKELY (priv->cached_name))
+		g_free (priv->cached_name);
+	priv->cached_name = NULL;
+
+	g_static_rec_mutex_unlock (priv->folder_lock);
+
 	/* g_static_rec_mutex_free (priv->folder_lock); */
 	g_free (priv->folder_lock);
 	priv->folder_lock = NULL;
@@ -6163,6 +6191,7 @@ tny_camel_folder_class_init (TnyCamelFolderClass *class)
 
 	parent_class = g_type_class_peek_parent (class);
 	object_class = (GObjectClass*) class;
+	object_class->dispose = tny_camel_folder_dispose;
 	object_class->finalize = tny_camel_folder_finalize;
 
 	class->add_msg_async= tny_camel_folder_add_msg_async_default;
diff --git a/libtinymail-camel/tny-camel-store-account.c b/libtinymail-camel/tny-camel-store-account.c
index f6feb12..f3dcbaa 100644
--- a/libtinymail-camel/tny-camel-store-account.c
+++ b/libtinymail-camel/tny-camel-store-account.c
@@ -798,9 +798,8 @@ notify_store_observer_del (gpointer user_data, GObject *observer)
 	g_static_rec_mutex_unlock (priv->obs_lock);
 }
 
-
 static void
-tny_camel_store_account_finalize (GObject *object)
+tny_camel_store_account_dispose (GObject *object)
 {
 	TnyCamelStoreAccount *self = (TnyCamelStoreAccount *)object;
 	TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self);
@@ -825,6 +824,18 @@ tny_camel_store_account_finalize (GObject *object)
 		camel_object_unref (CAMEL_OBJECT (priv->iter_store));
 	}
 
+	g_object_unref (priv->msg_queue);
+
+	return;
+}
+
+
+static void
+tny_camel_store_account_finalize (GObject *object)
+{
+	TnyCamelStoreAccount *self = (TnyCamelStoreAccount *)object;
+	TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self);
+
 	/* g_static_rec_mutex_free (priv->factory_lock); */
 	g_free (priv->factory_lock);
 	priv->factory_lock = NULL;
@@ -833,8 +844,6 @@ tny_camel_store_account_finalize (GObject *object)
 	g_free (priv->obs_lock);
 	priv->obs_lock = NULL;
 
-	g_object_unref (priv->msg_queue);
-
 	(*parent_class->finalize) (object);
 
 	return;
@@ -2085,6 +2094,7 @@ tny_camel_store_account_class_init (TnyCamelStoreAccountClass *class)
 	parent_class = g_type_class_peek_parent (class);
 	object_class = (GObjectClass*) class;
 
+	object_class->dispose = tny_camel_store_account_dispose;
 	object_class->finalize = tny_camel_store_account_finalize;
 
 	TNY_CAMEL_ACCOUNT_CLASS (class)->try_connect= tny_camel_store_account_try_connect;
-- 
1.5.4.3


--------------040209010609030806090308
Content-Type: text/x-diff;
 name="0002-Give-tny_folder_store_get_folders-a-refresh-paramete.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename*0="0002-Give-tny_folder_store_get_folders-a-refresh-paramete.pa";
 filename*1="tch"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]