2007-07-23 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Mon, 23 Jul 2007 12:07:22 +0000 (12:07 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Mon, 23 Jul 2007 12:07:22 +0000 (12:07 +0000)
* src/modest-tny-account.c:
(modest_tny_account_get_special_folder): Use an if instead of
an assert for when the parent account name is NULL, because this
might be causing a crash in projects.maemo.org bug 63192.
* src/modest-mail-operation.c:
(modest_mail_operation_send_new_mail_cb),
(modest_mail_operation_remove_folder): unref the folder that is
returned from modest_tny_account_get_special_folder().

pmo-trunk-r2770

ChangeLog2
src/modest-mail-operation.c
src/modest-tny-account.c
src/modest-tny-account.h

index 9235a1c..ab6782d 100644 (file)
@@ -1,5 +1,16 @@
 2007-07-23  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/modest-tny-account.c:
+       (modest_tny_account_get_special_folder): Use an if instead of 
+       an assert for when the parent account name is NULL, because this 
+       might be causing a crash in projects.maemo.org bug 63192.
+       * src/modest-mail-operation.c:
+       (modest_mail_operation_send_new_mail_cb),
+       (modest_mail_operation_remove_folder): unref the folder that is 
+       returned from modest_tny_account_get_special_folder().
+
+2007-07-23  Murray Cumming  <murrayc@murrayc.com>
+
        * src/modest-ui-actions.c:
        (modest_ui_actions_on_password_requested):
        Show mail_ib_login_cancelled info banner when the user cancels 
index 70b0bdb..39dbea7 100644 (file)
@@ -717,6 +717,7 @@ modest_mail_operation_send_new_mail_cb (ModestMailOperation *self,
                        tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED);
                        tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
                        g_object_unref (header);
+                       g_object_unref (folder);
                }
        }
 
@@ -1585,9 +1586,12 @@ modest_mail_operation_remove_folder (ModestMailOperation *self,
                trash_folder = modest_tny_account_get_special_folder (account,
                                                                      TNY_FOLDER_TYPE_TRASH);
                /* TODO: error_handling */
-                modest_mail_operation_xfer_folder (self, folder,
+               if (trash_folder) {
+                       modest_mail_operation_xfer_folder (self, folder,
                                                    TNY_FOLDER_STORE (trash_folder), 
                                                    TRUE, NULL, NULL);
+                       g_object_unref (trash_folder);
+               }
        } else {
                TnyFolderStore *parent = tny_folder_get_folder_store (folder);
 
index f9a2b10..c5fb06f 100644 (file)
@@ -74,21 +74,24 @@ modest_tny_account_get_special_folder (TnyAccount *account,
        if (special_type == TNY_FOLDER_TYPE_OUTBOX) {
                const gchar *modest_account_name = 
                        modest_tny_account_get_parent_modest_account_name_for_server_account (account);
-               g_assert (modest_account_name);
-
-               gchar *account_id = g_strdup_printf (
-                       MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s", 
-                       modest_account_name);
                
-               local_account = modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
-                                                                            MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
-                                                                            account_id);
-               if (!local_account) {
-                       g_printerr ("modest: %s: modest_tny_account_store_get_tny_account_by(ID) returned NULL for %s\n", __FUNCTION__, account_id);
-               return NULL;
+               if (modest_account_name) {
+                       gchar *account_id = g_strdup_printf (
+                               MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s", 
+                               modest_account_name);
+                       
+                       local_account = modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
+                                                                                    MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+                                                                                    account_id);
+                       if (!local_account) {
+                               g_printerr ("modest: %s: modest_tny_account_store_get_tny_account_by(ID) returned NULL for %s\n", __FUNCTION__, account_id);
+                       return NULL;
+                       }
+               
+                       g_free (account_id);
+               } else {
+                       g_warning ("%s: modest_account_name was NULL.", __FUNCTION);
                }
-       
-               g_free (account_id);
        } else {
                /* Other local folders are all in one on-disk directory: */
                local_account = modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
@@ -128,7 +131,7 @@ modest_tny_account_get_special_folder (TnyAccount *account,
                        TNY_FOLDER (tny_iterator_get_current (iter));
                if (modest_tny_folder_get_local_folder_type (folder) == special_type) {
                        special_folder = folder;
-                       break;
+                       break; /* Leaving a ref for the special_folder return value. */
                }
                
                g_object_unref (G_OBJECT(folder));
index 08e844a..867f19a 100644 (file)
@@ -115,7 +115,8 @@ modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
  * such as (for example) server-side Sent/Junk mail for IMAP accounts 
  * 
  * Returns: the tny folder corresponding to this special folder, or NULL in case
- * of error, or if the special folder does not exist for this account
+ * of error, or if the special folder does not exist for this account. 
+ * This must be unrefed with g_object_unref().
  */
 TnyFolder*    modest_tny_account_get_special_folder   (TnyAccount *self,
                                                       TnyFolderType special_type);