From: Sergio Villar Senin Date: Thu, 21 Feb 2008 10:55:06 +0000 (+0000) Subject: * Fixed a lot of reference leaks X-Git-Tag: git_migration_finished~1640 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=2290a841d02ff9980feb86a96c2ac341b4dd0511 * Fixed a lot of reference leaks * Updated some documentation pmo-trunk-r4218 --- diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 1275b8e..7530237 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -459,7 +459,8 @@ on_open_message_performer (gboolean canceled, account_store = modest_runtime_get_account_store (); local_folders_account = MODEST_TNY_LOCAL_FOLDERS_ACCOUNT ( modest_tny_account_store_get_local_folders_account (account_store)); - folder = modest_tny_local_folders_account_get_merged_outbox (local_folders_account); + folder = modest_tny_local_folders_account_get_merged_outbox (local_folders_account); + g_object_unref (local_folders_account); } else { folder = tny_store_account_find_folder (TNY_STORE_ACCOUNT (account), uri, NULL); } @@ -592,6 +593,7 @@ on_open_message (GArray * arguments, gpointer data, osso_rpc_t * retval) local_folders_account = MODEST_TNY_LOCAL_FOLDERS_ACCOUNT ( modest_tny_account_store_get_local_folders_account (account_store)); folder = modest_tny_local_folders_account_get_merged_outbox (local_folders_account); + g_object_unref (local_folders_account); } if (folder) { TnyMsg *msg = tny_folder_find_msg (folder, uri, NULL); diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index c600a9c..843d499 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -2297,9 +2297,10 @@ on_mail_operation_started (ModestMailOperation *mail_op, is_remote = !(modest_tny_account_is_virtual_local_folders (account) || modest_tny_account_is_memory_card_account (account)); - g_object_unref (account); - if (!is_remote) + if (!is_remote) { + g_object_unref (account); return; + } /* Show information banner. Remove old timeout */ if (priv->retrieving_banner_timeout > 0) { @@ -2310,6 +2311,7 @@ on_mail_operation_started (ModestMailOperation *mail_op, priv->retrieving_banner_timeout = g_timeout_add (2000, show_retrieving_banner, self); } + g_object_unref (account); /* Get toolbar mode from operation id*/ mode = get_toolbar_mode_from_mail_operation (self, mail_op, &mode_changed); @@ -2361,9 +2363,10 @@ on_mail_operation_finished (ModestMailOperation *mail_op, is_remote = !(modest_tny_account_is_virtual_local_folders (account) || modest_tny_account_is_memory_card_account (account)); - g_object_unref (account); - if (!is_remote) + if (!is_remote) { + g_object_unref (account); return; + } /* Remove old timeout */ if (priv->retrieving_banner_timeout > 0) { @@ -2377,6 +2380,7 @@ on_mail_operation_finished (ModestMailOperation *mail_op, priv->retrieving_banner = NULL; } } + g_object_unref (account); /* Get toolbar mode from operation id*/ mode = get_toolbar_mode_from_mail_operation (self, mail_op, &mode_changed); diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index cea772e..7aa6282 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -1223,7 +1223,7 @@ inbox_refreshed_cb (TnyFolder *inbox, ModestAccountRetrieveType retrieve_type; TnyList *new_headers = NULL; gboolean headers_only, ignore_limit; - TnyTransportAccount *transport_account; + TnyTransportAccount *transport_account = NULL; info = (UpdateAccountInfo *) user_data; priv = MODEST_MAIL_OPERATION_GET_PRIVATE (info->mail_op); @@ -1345,6 +1345,7 @@ inbox_refreshed_cb (TnyFolder *inbox, guint num_messages; send_queue = modest_runtime_get_send_queue (transport_account); + g_object_unref (transport_account); /* Get outbox folder */ outbox = tny_send_queue_get_outbox (TNY_SEND_QUEUE (send_queue)); @@ -1366,7 +1367,7 @@ inbox_refreshed_cb (TnyFolder *inbox, /* Try to send */ tny_camel_send_queue_flush (TNY_CAMEL_SEND_QUEUE (send_queue)); } - } + } /* Check if the operation was a success */ if (!priv->error) @@ -1490,7 +1491,6 @@ modest_mail_operation_update_account (ModestMailOperation *self, UpdateAccountInfo *info = NULL; ModestMailOperationPrivate *priv = NULL; ModestTnyAccountStore *account_store = NULL; - TnyStoreAccount *store_account = NULL; TnyList *folders; ModestMailOperationState *state; @@ -1503,11 +1503,10 @@ modest_mail_operation_update_account (ModestMailOperation *self, /* Get the store account */ account_store = modest_runtime_get_account_store (); - store_account = (TnyStoreAccount *) + priv->account = modest_tny_account_store_get_server_account (account_store, account_name, TNY_ACCOUNT_TYPE_STORE); - priv->account = g_object_ref (store_account); /* Create the helper object */ info = g_slice_new0 (UpdateAccountInfo); @@ -1535,7 +1534,7 @@ modest_mail_operation_update_account (ModestMailOperation *self, /* Get all folders and continue in the callback */ folders = tny_simple_list_new (); - tny_folder_store_get_folders_async (TNY_FOLDER_STORE (store_account), + tny_folder_store_get_folders_async (TNY_FOLDER_STORE (priv->account), folders, NULL, recurse_folders_async_cb, NULL, info); @@ -1702,7 +1701,6 @@ modest_mail_operation_remove_folder (ModestMailOperation *self, TnyFolder *folder, gboolean remove_to_trash) { - TnyAccount *account; ModestMailOperationPrivate *priv; ModestTnyFolderRules rules; @@ -1723,14 +1721,13 @@ modest_mail_operation_remove_folder (ModestMailOperation *self, } /* Get the account */ - account = modest_tny_folder_get_account (folder); - priv->account = g_object_ref(account); + priv->account = modest_tny_folder_get_account (folder); priv->op_type = MODEST_MAIL_OPERATION_TYPE_DELETE; /* Delete folder or move to trash */ if (remove_to_trash) { TnyFolder *trash_folder = NULL; - trash_folder = modest_tny_account_get_special_folder (account, + trash_folder = modest_tny_account_get_special_folder (priv->account, TNY_FOLDER_TYPE_TRASH); /* TODO: error_handling */ if (trash_folder) { @@ -1756,7 +1753,6 @@ modest_mail_operation_remove_folder (ModestMailOperation *self, } else g_warning ("%s: could not get parent folder", __FUNCTION__); } - g_object_unref (G_OBJECT (account)); end: /* Notify about operation end */ diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 6fbc996..3bf4ac3 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -1486,6 +1486,7 @@ modest_tny_account_store_get_mmc_folders_account (ModestTnyAccountStore *self) { g_return_val_if_fail (MODEST_IS_TNY_ACCOUNT_STORE (self), NULL); + /* New reference */ return modest_tny_account_store_get_tny_account_by (self, MODEST_TNY_ACCOUNT_STORE_QUERY_ID, MODEST_MMC_ACCOUNT_ID); @@ -1900,7 +1901,8 @@ modest_tny_account_store_get_transport_account_from_outbox_header(ModestTnyAccou g_object_unref (account); tny_iterator_next (acc_iter); } - g_object_unref(acc_iter); + + /* New reference */ return header_acc; } diff --git a/src/modest-tny-account-store.h b/src/modest-tny-account-store.h index a7f7c5d..d90111a 100644 --- a/src/modest-tny-account-store.h +++ b/src/modest-tny-account-store.h @@ -168,7 +168,8 @@ TnySessionCamel* modest_tny_account_store_get_session (TnyAccountStore *se /** modest_tny_account_store_get_local_folders_account: * @self: a TnyAccountStore instance * - * Get the user-visible local folders account. + * Get the user-visible local folders account. It returns a new + * reference so the caller must unref it when no longer needed **/ TnyAccount * modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self); @@ -178,7 +179,9 @@ TnyAccount * modest_tny_account_store_get_local_folders_account (ModestTnyAccoun * * Get the mmc folders account. * - * Returns: a #TnyAccount, or %NULL if no mmc account is available now. + * Returns: a #TnyAccount, or %NULL if no mmc account is available + * now. It returns a new reference so the caller must unref it when no + * longer needed */ TnyAccount * modest_tny_account_store_get_mmc_folders_account (ModestTnyAccountStore *self); @@ -212,11 +215,11 @@ TnyMsg *modest_tny_account_store_find_msg_in_outboxes (ModestTnyAccountStore *se * * Gets the transport account from a header that is in the outbox * - * Returns: %NULL or a %TnyTransportAccount + * Returns: %NULL or a %TnyTransportAccount. Returns a new reference + * so the caller must unref it when no longer needed */ -TnyTransportAccount * -modest_tny_account_store_get_transport_account_from_outbox_header(ModestTnyAccountStore *self, - TnyHeader *header); +TnyTransportAccount * modest_tny_account_store_get_transport_account_from_outbox_header(ModestTnyAccountStore *self, + TnyHeader *header); /** * modest_tny_account_store_new_connection_specific_transport_account: @@ -227,9 +230,8 @@ modest_tny_account_store_get_transport_account_from_outbox_header(ModestTnyAccou * * Returns: the new #TnyTransportAccount */ -TnyTransportAccount * -modest_tny_account_store_new_connection_specific_transport_account (ModestTnyAccountStore *self, - const gchar *name); +TnyTransportAccount * modest_tny_account_store_new_connection_specific_transport_account (ModestTnyAccountStore *self, + const gchar *name); G_END_DECLS diff --git a/src/modest-transport-account-decorator.c b/src/modest-transport-account-decorator.c index 177027e..147ea05 100644 --- a/src/modest-transport-account-decorator.c +++ b/src/modest-transport-account-decorator.c @@ -85,6 +85,7 @@ modest_transport_account_decorator_send (TnyTransportAccount *self, TnyMsg *msg, if (connection_specific_account) { tny_transport_account_send (connection_specific_account, msg, err); + g_object_unref (connection_specific_account); } else { TNY_CAMEL_TRANSPORT_ACCOUNT_CLASS(parent_class)->send (self, msg, err); } diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 6a54523..3451b38 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -4041,6 +4041,7 @@ on_move_to_dialog_folder_selection_changed (ModestFolderView* self, new_sensitive = (proto != MODEST_PROTOCOL_STORE_POP); } g_object_unref (local_account); + g_object_unref (mmc_account); } /* Check the target folder rules */