From 60070e492a8b67dd8f245a676f9d6e7188684aa9 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Mon, 7 Apr 2008 17:53:06 +0000 Subject: [PATCH] * Partially fixes NB#83671, fixes several reference leaks and remove passwords in memory when removing accounts pmo-trunk-r4376 --- src/maemo/modest-platform.c | 24 ++++++++++-------------- src/modest-mail-operation.c | 3 ++- src/modest-tny-account-store.c | 19 ++++++++++++------- src/modest-tny-folder.c | 6 ++++-- src/widgets/modest-header-view.c | 2 +- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index ae0c3a4..d2e97b4 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -2144,32 +2144,28 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window, } else if (TNY_IS_FOLDER (folder_store)) { /* Get the folder's parent account: */ - account = tny_folder_get_account(TNY_FOLDER (folder_store)); + account = tny_folder_get_account (TNY_FOLDER (folder_store)); } else if (TNY_IS_ACCOUNT (folder_store)) { /* Use the folder store as an account: */ - account = TNY_ACCOUNT (folder_store); + account = TNY_ACCOUNT (g_object_ref (folder_store)); } if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) { if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) && !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) { - - /* This IS a local account like a maildir account, which does not require - * a connection. (original comment had a vague assumption in its language - * usage. There's no assuming needed, this IS what it IS: a local account), */ - /* We promise to instantly perform the callback, so ... */ - if (callback) { + /* No need to connect a local account */ + if (callback) callback (FALSE, NULL, parent_window, account, user_data); - } - - return; + + goto clean; } } + modest_platform_connect_and_perform (parent_window, force, account, callback, user_data); - modest_platform_connect_and_perform (parent_window, force, account, callback, user_data); - - return; + clean: + if (account) + g_object_unref (account); } static void diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 59eee34..f6a3217 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -2109,10 +2109,11 @@ modest_mail_operation_rename_folder (ModestMailOperation *self, transfer_folder_cb, transfer_folder_status_cb, helper); + g_object_unref (into); } else { + g_object_unref (into); goto error; } - g_object_unref (into); return; } diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 59ea876..a07427d 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -103,8 +103,8 @@ static void on_vfs_volume_unmounted (GnomeVFSVolumeMonitor *volume_monito GnomeVFSVolume *volume, gpointer user_data); -static void modest_tny_account_store_forget_password_in_memory (ModestTnyAccountStore *self, - const gchar *server_account_name); +static void forget_password_in_memory (ModestTnyAccountStore *self, + const gchar *server_account_name); static void add_connection_specific_transport_accounts (ModestTnyAccountStore *self); @@ -434,7 +434,7 @@ on_vfs_volume_unmounted(GnomeVFSVolumeMonitor *volume_monitor, } /** - * modest_tny_account_store_forget_password_in_memory + * forget_password_in_memory * @self: a TnyAccountStore instance * @account: A server account. * @@ -442,9 +442,9 @@ on_vfs_volume_unmounted(GnomeVFSVolumeMonitor *volume_monitor, * For instance, this should be called when the user has changed the password in the account settings. */ static void -modest_tny_account_store_forget_password_in_memory (ModestTnyAccountStore *self, const gchar * server_account_name) +forget_password_in_memory (ModestTnyAccountStore *self, + const gchar * server_account_name) { - /* printf ("DEBUG: %s\n", __FUNCTION__); */ ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self); if (server_account_name && priv->password_hash) { @@ -1570,8 +1570,7 @@ create_tny_account (ModestTnyAccountStore *self, if (account) { /* Forget any cached password for the account, so that we use a new account if any */ - modest_tny_account_store_forget_password_in_memory (self, - tny_account_get_id (account)); + forget_password_in_memory (self, tny_account_get_id (account)); /* Install a signal handler that will refresh the account the first time it becomes online. Do this @@ -1767,6 +1766,9 @@ on_account_removed (ModestAccountMgr *acc_mgr, /* If there was any problem creating the account, for example, with the configuration system this could not exist */ if (store_account) { + /* Forget any cached password for the account */ + forget_password_in_memory (self, tny_account_get_id (store_account)); + /* Remove it from the list of accounts and notify the observers. Do not need to wait for account disconnection */ @@ -1791,6 +1793,9 @@ on_account_removed (ModestAccountMgr *acc_mgr, TnyAccount *local_account = NULL; TnyFolder *outbox = NULL; + /* Forget any cached password for the account */ + forget_password_in_memory (self, tny_account_get_id (store_account)); + /* Remove it from the list of accounts and notify the observers. Do not need to wait for account disconnection */ diff --git a/src/modest-tny-folder.c b/src/modest-tny-folder.c index 381cc64..915c787 100644 --- a/src/modest-tny-folder.c +++ b/src/modest-tny-folder.c @@ -245,10 +245,12 @@ modest_tny_folder_is_memory_card_folder (TnyFolder *folder) return FALSE; const gchar* account_id = tny_account_get_id (account); - if (!account_id) + if (!account_id) { + g_object_unref (account); return FALSE; + } - g_object_unref (G_OBJECT(account)); + g_object_unref (account); return (strcmp (account_id, MODEST_MMC_ACCOUNT_ID) == 0); } diff --git a/src/widgets/modest-header-view.c b/src/widgets/modest-header-view.c index f46f2a7..cee8ad6 100644 --- a/src/widgets/modest-header-view.c +++ b/src/widgets/modest-header-view.c @@ -2080,7 +2080,7 @@ on_account_removed (TnyAccountStore *self, my_account = tny_folder_get_account (priv->folder); if (my_account == account) modest_header_view_clear (MODEST_HEADER_VIEW (user_data)); - g_object_unref (account); + g_object_unref (my_account); } } -- 1.7.9.5