2007-07-23 Murray Cumming <murrayc@murrayc.com>
[modest] / src / modest-mail-operation.c
index a1c308d..39dbea7 100644 (file)
@@ -417,7 +417,8 @@ modest_mail_operation_cancel (ModestMailOperation *self)
        /* Cancel the mail operation. We need to wrap it between this
           start/stop operations to allow following calls to the
           account */
-       tny_account_cancel (priv->account);
+       if (priv->account)
+               tny_account_cancel (priv->account);
 
        return canceled;
 }
@@ -716,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);
                }
        }
 
@@ -1139,14 +1141,14 @@ static gpointer
 update_account_thread (gpointer thr_user_data)
 {
        static gboolean first_time = TRUE;
-       UpdateAccountInfo *info;
+       UpdateAccountInfo *info = NULL;
        TnyList *all_folders = NULL;
        GPtrArray *new_headers = NULL;
        TnyIterator *iter = NULL;
        TnyFolderStoreQuery *query = NULL;
        ModestMailOperationPrivate *priv = NULL;
        ModestTnySendQueue *send_queue = NULL;
-       gint num_new_headers;
+       gint num_new_headers = 0;
 
        info = (UpdateAccountInfo *) thr_user_data;
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(info->mail_op);
@@ -1584,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);