2008-09-04 [colin] 3.5.0cvs89
authorColin Leroy <colin@colino.net>
Thu, 4 Sep 2008 08:06:09 +0000 (08:06 +0000)
committerColin Leroy <colin@colino.net>
Thu, 4 Sep 2008 08:06:09 +0000 (08:06 +0000)
* src/summaryview.c
Fix bug 1707, 'Segfault when sorting on non-visible column'

ChangeLog
PATCHSETS
configure.ac
src/summaryview.c

index 9855cd3..1e0a977 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-04 [colin]     3.5.0cvs89
+
+       * src/summaryview.c
+               Fix bug 1707, 'Segfault when sorting on non-visible column'
+
 2008-09-01 [colin]     3.5.0cvs88
 
        * src/imap.c
index fcdd298..76a3e11 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.60.2.123 -r 1.60.2.124 src/addressbook.c;  ) > 3.5.0cvs86.patchset
 ( cvs diff -u -r 1.396.2.2646 -r 1.396.2.2647 ChangeLog;  ) > 3.5.0cvs87.patchset
 ( cvs diff -u -r 1.179.2.226 -r 1.179.2.227 src/imap.c;  cvs diff -u -r 1.395.2.387 -r 1.395.2.388 src/summaryview.c;  cvs diff -u -r 1.1.2.7 -r 1.1.2.8 src/common/tags.c;  cvs diff -u -r 1.1.4.103 -r 1.1.4.104 src/etpan/imap-thread.c;  cvs diff -u -r 1.1.4.24 -r 1.1.4.25 src/etpan/imap-thread.h;  ) > 3.5.0cvs88.patchset
+( cvs diff -u -r 1.395.2.388 -r 1.395.2.389 src/summaryview.c;  ) > 3.5.0cvs89.patchset
index 422d445..0b731e6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=88
+EXTRA_VERSION=89
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 58bb293..c3f6265 100644 (file)
@@ -7107,16 +7107,31 @@ static void summary_drag_data_received(GtkWidget        *widget,
 
 /* custom compare functions for sorting */
 
+static gint summary_cmp_by_date(GtkCMCList *clist,
+                     gconstpointer ptr1, gconstpointer ptr2)
+{
+       MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data;
+       MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data;
+       gint res;
+       if (!msginfo1 || !msginfo2)
+               return -1;
+
+       res = (msginfo1->date_t - msginfo2->date_t);
+       return res;
+}
+
 #define CMP_FUNC_DEF(func_name, val)                                    \
-static gint func_name(GtkCMCList *clist,                                        \
+static gint func_name(GtkCMCList *clist,                                \
                      gconstpointer ptr1, gconstpointer ptr2)            \
 {                                                                       \
        MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data;               \
        MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data;               \
+       gint res;                                                        \
        if (!msginfo1 || !msginfo2)                                      \
                return -1;                                               \
                                                                         \
-       return (val);                                                    \
+       res = (val);                                                     \
+       return (res != 0) ? res:summary_cmp_by_date(clist, ptr1, ptr2);  \
 }
 
 CMP_FUNC_DEF(summary_cmp_by_mark,
@@ -7134,7 +7149,6 @@ CMP_FUNC_DEF(summary_cmp_by_locked,
 
 CMP_FUNC_DEF(summary_cmp_by_num, msginfo1->msgnum - msginfo2->msgnum)
 CMP_FUNC_DEF(summary_cmp_by_size, msginfo1->size - msginfo2->size)
-CMP_FUNC_DEF(summary_cmp_by_date, msginfo1->date_t - msginfo2->date_t)
 
 #undef CMP_FUNC_DEF
 
@@ -7176,13 +7190,19 @@ static gint summary_cmp_by_from(GtkCMCList *clist, gconstpointer ptr1,
        const gchar *str1, *str2;
        const GtkCMCListRow *r1 = (const GtkCMCListRow *) ptr1;
        const GtkCMCListRow *r2 = (const GtkCMCListRow *) ptr2;
+       MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data;
+       MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data;
        const SummaryView *sv = g_object_get_data(G_OBJECT(clist), "summaryview");
        gint res;
 
        g_return_val_if_fail(sv, -1);
-       
-       str1 = GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_FROM]])->text;
-       str2 = GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_FROM]])->text;
+       if (sv->col_state[sv->col_pos[S_COL_FROM]].visible) {
+               str1 = GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_FROM]])->text;
+               str2 = GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_FROM]])->text;
+       } else {
+               str1 = msginfo1->from;
+               str2 = msginfo2->from;
+       }
 
        if (!str1)
                return str2 != NULL;
@@ -7200,12 +7220,19 @@ static gint summary_cmp_by_to(GtkCMCList *clist, gconstpointer ptr1,
        const gchar *str1, *str2;
        const GtkCMCListRow *r1 = (const GtkCMCListRow *) ptr1;
        const GtkCMCListRow *r2 = (const GtkCMCListRow *) ptr2;
+       MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data;
+       MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data;
        const SummaryView *sv = g_object_get_data(G_OBJECT(clist), "summaryview");
        gint res;
        g_return_val_if_fail(sv, -1);
        
-       str1 = GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_TO]])->text;
-       str2 = GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_TO]])->text;
+       if (sv->col_state[sv->col_pos[S_COL_TO]].visible) {
+               str1 = GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_TO]])->text;
+               str2 = GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_TO]])->text;
+       } else {
+               str1 = msginfo1->to;
+               str2 = msginfo2->to;
+       }
 
        if (!str1)
                return str2 != NULL;
@@ -7220,23 +7247,36 @@ static gint summary_cmp_by_to(GtkCMCList *clist, gconstpointer ptr1,
 static gint summary_cmp_by_tags(GtkCMCList *clist, gconstpointer ptr1,
                                gconstpointer ptr2)
 {
-       const gchar *str1, *str2;
+       gchar *str1, *str2;
        const GtkCMCListRow *r1 = (const GtkCMCListRow *) ptr1;
        const GtkCMCListRow *r2 = (const GtkCMCListRow *) ptr2;
        const SummaryView *sv = g_object_get_data(G_OBJECT(clist), "summaryview");
+       MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data;
+       MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data;
        gint res;
        g_return_val_if_fail(sv, -1);
        
-       str1 = GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_TAGS]])->text;
-       str2 = GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_TAGS]])->text;
+       if (sv->col_state[sv->col_pos[S_COL_TAGS]].visible) {
+               str1 = g_strdup(GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_TAGS]])->text);
+               str2 = g_strdup(GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_TAGS]])->text);
+       } else {
+               str1 = procmsg_msginfo_get_tags_str(msginfo1);
+               str2 = procmsg_msginfo_get_tags_str(msginfo2);
+       }
 
-       if (!str1)
-               return str2 != NULL;
-       if (!str2)
+       if (!str1) {
+               res = (str2 != NULL);
+               g_free(str2);
+               return res;
+       }
+       if (!str2) {
+               g_free(str1);
                return -1;
+       }
  
        res = g_utf8_collate(str1, str2);
+       g_free(str1);
+       g_free(str2);
        return (res != 0)? res: summary_cmp_by_date(clist, ptr1, ptr2);
 }
  
@@ -7255,8 +7295,13 @@ static gint summary_cmp_by_simplified_subject
        g_return_val_if_fail(sv, -1);
        g_return_val_if_fail(msginfo1 != NULL && msginfo2 != NULL, -1);
        
-       str1 = GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_SUBJECT]])->text;
-       str2 = GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_SUBJECT]])->text;
+       if (sv->col_state[sv->col_pos[S_COL_SUBJECT]].visible) {
+               str1 = GTK_CMCELL_TEXT(r1->cell[sv->col_pos[S_COL_SUBJECT]])->text;
+               str2 = GTK_CMCELL_TEXT(r2->cell[sv->col_pos[S_COL_SUBJECT]])->text;
+       } else {
+               str1 = msginfo1->subject;
+               str2 = msginfo2->subject;
+       }
 
        if (!str1)
                return str2 != NULL;