2006-08-22 [colin] 2.4.0cvs73
[claws.git] / src / procmsg.c
index 208c3bc4664229e4ddeeea7247662f373785fddb..85c889e19812a8d5f6c46bc04c029405e3ed74af 100644 (file)
@@ -46,6 +46,7 @@
 #include "summaryview.h"
 #include "log.h"
 #include "timing.h"
+#include "inc.h"
 
 static gint procmsg_send_message_queue_full(const gchar *file, gboolean keep_session, gchar **errstr);
 
@@ -250,8 +251,11 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
        START_TIMING("procmsg_get_thread_tree");
        root = g_node_new(NULL);
        msgid_table = g_hash_table_new(g_str_hash, g_str_equal);
-       subject_relation = g_relation_new(2);
-       g_relation_index(subject_relation, 0, g_str_hash, g_str_equal);
+       
+       if (prefs_common.thread_by_subject) {
+               subject_relation = g_relation_new(2);
+               g_relation_index(subject_relation, 0, g_str_hash, g_str_equal);
+       }
 
        for (; mlist != NULL; mlist = mlist->next) {
                msginfo = (MsgInfo *)mlist->data;
@@ -333,7 +337,9 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
                END_TIMING();
        }
        
-       g_relation_destroy(subject_relation);
+       if (prefs_common.thread_by_subject)
+               g_relation_destroy(subject_relation);
+
        g_hash_table_destroy(msgid_table);
        END_TIMING();
        return root;
@@ -906,11 +912,13 @@ gint procmsg_send_queue(FolderItem *queue, gboolean save_msgs, gchar **errstr)
                return -1;
        }
        send_queue_lock = TRUE;
+       inc_lock();
        if (!queue)
                queue = folder_get_default_queue();
        
        if (queue == NULL) {
                send_queue_lock = FALSE;
+               inc_unlock();
                return -1;
        }
 
@@ -966,6 +974,7 @@ gint procmsg_send_queue(FolderItem *queue, gboolean save_msgs, gchar **errstr)
                }
        }
        send_queue_lock = FALSE;
+       inc_unlock();
        toolbar_main_set_sensitive(mainwindow_get_mainwindow());
 
        return (err != 0 ? -err : sent);
@@ -1084,7 +1093,6 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
                        g_warning("can't save message\n");
                        return -1;
                }
-               return 0;
        }
        msginfo = folder_item_get_msginfo(outbox, num);         /* refcnt++ */
        tmp_msginfo = procmsg_msginfo_get_full_info(msginfo);   /* refcnt++ */ 
@@ -1095,8 +1103,8 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
                if (tmp_msginfo && (msginfo->dispositionnotificationto || 
                    msginfo->returnreceiptto)) {
                        procmsg_msginfo_set_flags(msginfo, MSG_RETRCPT_SENT, 0); 
-                       procmsg_msginfo_free(msginfo);          /* refcnt-- */
                }       
+               procmsg_msginfo_free(tmp_msginfo);              /* refcnt-- */
        }
 
        return 0;