* Fixed a lot of reference leaks
authorSergio Villar Senin <svillar@igalia.com>
Thu, 21 Feb 2008 10:55:06 +0000 (10:55 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Thu, 21 Feb 2008 10:55:06 +0000 (10:55 +0000)
* Updated some documentation

pmo-trunk-r4218

src/dbus_api/modest-dbus-callbacks.c
src/maemo/modest-main-window.c
src/modest-mail-operation.c
src/modest-tny-account-store.c
src/modest-tny-account-store.h
src/modest-transport-account-decorator.c
src/modest-ui-actions.c

index 1275b8e..7530237 100644 (file)
@@ -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));
                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);
        }
        } 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);
                        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);
                }
                if (folder) {
                        TnyMsg *msg = tny_folder_find_msg (folder, uri, NULL);
index c600a9c..843d499 100644 (file)
@@ -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));
 
                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;
                        return;
+               }
 
                /* Show information banner. Remove old timeout */
                if (priv->retrieving_banner_timeout > 0) {
 
                /* 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);
        }
                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);
               
        /* 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));
 
                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;
                        return;
+               }
 
                /* Remove old timeout */
                if (priv->retrieving_banner_timeout > 0) {
 
                /* Remove old timeout */
                if (priv->retrieving_banner_timeout > 0) {
@@ -2377,6 +2380,7 @@ on_mail_operation_finished (ModestMailOperation *mail_op,
                        priv->retrieving_banner = NULL;
                }
        }
                        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);
 
        /* Get toolbar mode from operation id*/
        mode = get_toolbar_mode_from_mail_operation (self, mail_op, &mode_changed);
index cea772e..7aa6282 100644 (file)
@@ -1223,7 +1223,7 @@ inbox_refreshed_cb (TnyFolder *inbox,
        ModestAccountRetrieveType retrieve_type;
        TnyList *new_headers = NULL;
        gboolean headers_only, ignore_limit;
        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);
 
        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);
                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));
 
                /* 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));
                }
                        /* Try to send */
                        tny_camel_send_queue_flush (TNY_CAMEL_SEND_QUEUE (send_queue));
                }
-       } 
+       }
 
        /* Check if the operation was a success */
        if (!priv->error)
 
        /* 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;
        UpdateAccountInfo *info = NULL;
        ModestMailOperationPrivate *priv = NULL;
        ModestTnyAccountStore *account_store = NULL;
-       TnyStoreAccount *store_account = NULL;
        TnyList *folders;
        ModestMailOperationState *state;
 
        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 ();
 
        /* 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);
                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);
 
        /* 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 ();
        
        /* 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);
                                            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)
 {
                                     TnyFolder           *folder,
                                     gboolean             remove_to_trash)
 {
-       TnyAccount *account;
        ModestMailOperationPrivate *priv;
        ModestTnyFolderRules rules;
 
        ModestMailOperationPrivate *priv;
        ModestTnyFolderRules rules;
 
@@ -1723,14 +1721,13 @@ modest_mail_operation_remove_folder (ModestMailOperation *self,
        }
 
        /* Get the account */
        }
 
        /* 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;
        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) {
                                                                      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__);
        }
                } else
                        g_warning ("%s: could not get parent folder", __FUNCTION__);
        }
-       g_object_unref (G_OBJECT (account));
 
  end:
        /* Notify about operation end */
 
  end:
        /* Notify about operation end */
index 6fbc996..3bf4ac3 100644 (file)
@@ -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);
        
 {
        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);
 
        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 (account);
                tny_iterator_next (acc_iter);
        }
-
        g_object_unref(acc_iter);
        g_object_unref(acc_iter);
+
+       /* New reference */
        return header_acc;
 }
        return header_acc;
 }
index a7f7c5d..d90111a 100644 (file)
@@ -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
  * 
 /** 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);
 
  **/
 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.
  *
  * 
  * 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);
 
  */
 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
  *
  *
  * 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:
 
 /**
  * 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
  */
  *
  * 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
 
 
 G_END_DECLS
 
index 177027e..147ea05 100644 (file)
@@ -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);
        
        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);
        }
        } else {
                TNY_CAMEL_TRANSPORT_ACCOUNT_CLASS(parent_class)->send (self, msg, err);
        }
index 6a54523..3451b38 100644 (file)
@@ -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);
                        new_sensitive = (proto != MODEST_PROTOCOL_STORE_POP);
                }
                g_object_unref (local_account);
+               g_object_unref (mmc_account);
        }
 
        /* Check the target folder rules */
        }
 
        /* Check the target folder rules */