[evolution-patches] fix for bug #33933 (message-list sorting)



This should probably go into 2.0.x as well...

The problem was that back in 1.4 when we sued different MessageList
objects per folder, I had implemented a sorting optimisation that cached
the collated keys for each subject string (and sender/to/etc - which is
odd because the sorter didn't actually use those, but ah well).

Anyways, now that we reuse the same "view", this hack no longer works
and in fact causes problems (as seen in the report).

My Fix simply removes the hack and changes the sort type in the etspec
file for Subject to be "collate"

-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com
? 33933.patch
? 55303-2.patch
? 55303.patch
? 59717.patch
? 62377.patch
? 62665.patch
? 62771-mailer.patch
? 62812.patch
? 63177.patch
? 64974.patch
? 65448.patch
? camel-imap-summary.c
? camel-imap-summary.h
? default/zh_CN/Makefile
? default/zh_CN/Makefile.in
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3546
diff -u -r1.3546 ChangeLog
--- ChangeLog	25 Jan 2005 10:30:17 -0000	1.3546
+++ ChangeLog	25 Jan 2005 20:33:39 -0000
@@ -1,3 +1,16 @@
+2005-01-25  Jeffrey Stedfast  <fejj novell com>
+
+	Fixes bug #33933
+
+	* message-list.etspec: Changed the compare type of the subject to
+	"collate" so it sorts properly.
+
+	* message-list.c (ml_tree_value_at): In the COL_SUBJECT_SORT case,
+	strip out "Re:"'s like get_normalised_string() did.
+	(get_normalised_string): Removed.
+	(main_folder_changed): Updated for the removal of the normalised
+	string hash.
+
 2005-01-25  Mengjie Yu  <meng-jie yu sun com>
 
 	* em-mailer-prefs.c: (restore_labels_clicked),
Index: message-list.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/message-list.c,v
retrieving revision 1.407
diff -u -r1.407 message-list.c
--- message-list.c	18 Jan 2005 06:09:31 -0000	1.407
+++ message-list.c	25 Jan 2005 20:33:40 -0000
@@ -146,13 +146,6 @@
 #define COL_SIZE_EXPANSION     (6.0)
 #define COL_SIZE_WIDTH_MIN     (32)
 
-enum {
-	NORMALISED_SUBJECT,
-	NORMALISED_FROM,
-	NORMALISED_TO,
-	NORMALISED_LAST,
-};
-
 /* #define SMART_ADDRESS_COMPARE */
 
 #ifdef SMART_ADDRESS_COMPARE
@@ -394,72 +387,6 @@
 	return info;
 }
 
-static const char *
-get_normalised_string (MessageList *message_list, CamelMessageInfo *info, int col)
-{
-	const char *string, *str;
-	char *normalised;
-	EPoolv *poolv;
-	int index;
-	
-	switch (col) {
-	case COL_SUBJECT_NORM:
-		string = camel_message_info_subject (info);
-		index = NORMALISED_SUBJECT;
-		break;
-	case COL_FROM_NORM:
-		string = camel_message_info_from (info);
-		index = NORMALISED_FROM;
-		break;
-	case COL_TO_NORM:
-		string = camel_message_info_to (info);
-		index = NORMALISED_TO;
-		break;
-	default:
-		string = NULL;
-		index = NORMALISED_LAST;
-		g_assert_not_reached ();
-	}
-	
-	/* slight optimisation */
-	if (string == NULL || string[0] == '\0')
-		return "";
-	
-	poolv = g_hash_table_lookup (message_list->normalised_hash, camel_message_info_uid (info));
-	if (poolv == NULL) {
-		poolv = e_poolv_new (NORMALISED_LAST);
-		g_hash_table_insert (message_list->normalised_hash, (char *) camel_message_info_uid (info), poolv);
-	} else {
-		str = e_poolv_get (poolv, index);
-		if (*str)
-			return str;
-	}
-	
-	if (col == COL_SUBJECT_NORM) {
-		const unsigned char *subject;
-		
-		subject = (const unsigned char *) string;
-		while (!g_ascii_strncasecmp (subject, "Re:", 3)) {
-			subject += 3;
-			
-			/* jump over any spaces */
-			while (*subject && isspace ((int) *subject))
-				subject++;
-		}
-		
-		/* jump over any spaces */
-		while (*subject && isspace ((int) *subject))
-			subject++;
-		
-		string = (const char *) subject;
-	}
-	
-	normalised = g_utf8_collate_key (string, -1);
-	e_poolv_set (poolv, index, normalised, TRUE);
-	
-	return e_poolv_get (poolv, index);
-}
-
 static void
 clear_selection(MessageList *ml, struct _MLSelection *selection)
 {
@@ -1211,13 +1138,25 @@
 	case COL_FROM:
 		str = camel_message_info_from (msg_info);
 		return (void *)(str ? str : "");
-	case COL_FROM_NORM:
-		return (void *) get_normalised_string (message_list, msg_info, col);
 	case COL_SUBJECT:
 		str = camel_message_info_subject (msg_info);
 		return (void *)(str ? str : "");
-	case COL_SUBJECT_NORM:
-		return (void *) get_normalised_string (message_list, msg_info, col);
+	case COL_SUBJECT_SORT:
+		if ((str = camel_message_info_subject (msg_info))) {
+			while (!g_ascii_strncasecmp (str, "Re:", 3)) {
+				str += 3;
+				
+				/* jump over any spaces */
+				while (*str && isspace ((int) *str))
+					str++;
+			}
+			
+			/* jump over any spaces */
+			while (*str && isspace ((int) *str))
+				str++;
+		}
+		
+		return (void *)(str ? str : "");
 	case COL_SENT:
 		return GINT_TO_POINTER (camel_message_info_date_sent(msg_info));
 	case COL_RECEIVED:
@@ -1225,8 +1164,6 @@
 	case COL_TO:
 		str = camel_message_info_to (msg_info);
 		return (void *)(str ? str : "");
-	case COL_TO_NORM:
-		return (void *) get_normalised_string (message_list, msg_info, col);
 	case COL_SIZE:
 		return GINT_TO_POINTER (camel_message_info_size(msg_info));
 	case COL_DELETED:
@@ -1815,8 +1752,6 @@
 	gtk_scrolled_window_set_vadjustment ((GtkScrolledWindow *) message_list, adjustment);
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (message_list), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
 	
-	message_list->normalised_hash = g_hash_table_new (g_str_hash, g_str_equal);
-	
 	message_list->hidden = NULL;
 	message_list->hidden_pool = NULL;
 	message_list->hide_before = ML_HIDE_NONE_START;
@@ -1847,12 +1782,6 @@
 }
 
 static void
-normalised_free (gpointer key, gpointer value, gpointer user_data)
-{
-	e_poolv_destroy (value);
-}
-
-static void
 message_list_destroy(GtkObject *object)
 {
 	MessageList *message_list = MESSAGE_LIST (object);
@@ -1917,9 +1846,6 @@
 	MessageList *message_list = MESSAGE_LIST (object);
 	struct _MessageListPrivate *p = message_list->priv;
 	
-	g_hash_table_foreach (message_list->normalised_hash, normalised_free, NULL);
-	g_hash_table_destroy (message_list->normalised_hash);
-	
 	if (message_list->thread_tree)
 		camel_folder_thread_messages_unref(message_list->thread_tree);
 
@@ -2722,17 +2648,6 @@
 	if (changes) {
 		d(printf("changed = %d added = %d removed = %d\n",
 			 changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len));
-		
-		for (i = 0; i < changes->uid_removed->len; i++) {
-			/* uncache the normalised strings for these uids */
-			EPoolv *poolv;
-			
-			poolv = g_hash_table_lookup (ml->normalised_hash, changes->uid_removed->pdata[i]);
-			if (poolv != NULL) {
-				g_hash_table_remove (ml->normalised_hash, changes->uid_removed->pdata[i]);
-				e_poolv_destroy (poolv);
-			}
-		}
 		
 		/* check if the hidden state has changed, if so modify accordingly, then regenerate */
 		if (ml->hidejunk || ml->hidedeleted)
Index: message-list.etspec
===================================================================
RCS file: /cvs/gnome/evolution/mail/message-list.etspec,v
retrieving revision 1.17
diff -u -r1.17 message-list.etspec
--- message-list.etspec	17 Jun 2002 19:58:22 -0000	1.17
+++ message-list.etspec	25 Jan 2005 20:33:40 -0000
@@ -7,15 +7,15 @@
 
   <ETableColumn model_col="3" _title="Attachment" pixbuf="attachment" expansion="0.0" minimum_width="18" resizable="false" cell="render_attachment" compare="integer" sortable="false"/>
 
-  <ETableColumn model_col="4" compare_col="14" _title="From" expansion="1.0" minimum_width="32" resizable="true" cell="render_text" compare="address_compare" search="string" priority="10"/>
+  <ETableColumn model_col="4" compare_col="4" _title="From" expansion="1.0" minimum_width="32" resizable="true" cell="render_text" compare="address_compare" search="string" priority="10"/>
 
-  <ETableColumn model_col="5" compare_col="15" _title="Subject" expansion="1.6" minimum_width="32" resizable="true" cell="render_tree" compare="string" search="string"/>
+  <ETableColumn model_col="5" compare_col="15" _title="Subject" expansion="1.6" minimum_width="32" resizable="true" cell="render_tree" compare="collate" search="string"/>
 
   <ETableColumn model_col="6" _title="Date" expansion="0.4" minimum_width="32" resizable="true" cell="render_date" compare="integer"/>
 
   <ETableColumn model_col="7" _title="Received" expansion="0.4" minimum_width="32" resizable="true" cell="render_date" compare="integer"/>
 
-  <ETableColumn model_col="8" compare_col="16" _title="To" expansion="1.0" minimum_width="32" resizable="true" cell="render_text" compare="address_compare" search="string" priority="5"/>
+  <ETableColumn model_col="8" compare_col="8" _title="To" expansion="1.0" minimum_width="32" resizable="true" cell="render_text" compare="address_compare" search="string" priority="5"/>
 
   <ETableColumn model_col="9" _title="Size" expansion="0.2" minimum_width="32" resizable="true" cell="render_size" compare="integer"/>
 
Index: message-list.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/message-list.h,v
retrieving revision 1.86
diff -u -r1.86 message-list.h
--- message-list.h	18 Jan 2005 06:09:31 -0000	1.86
+++ message-list.h	25 Jan 2005 20:33:40 -0000
@@ -58,14 +58,14 @@
 	COL_FOLLOWUP_DUE_BY,
 	COL_LOCATION,		/* vfolder location? */
 	
-	/* normalised strings */
-	COL_FROM_NORM,
-	COL_SUBJECT_NORM,
-	COL_TO_NORM,
-	
 	COL_LAST,
 	
 	/* Invisible columns */
+	
+	/* Sorting columns */
+	COL_SUBJECT_SORT,
+	
+	/* State columns */
 	COL_DELETED,
 	COL_UNREAD,
 	COL_COLOUR,
@@ -95,8 +95,6 @@
 	char *folder_uri;
 
 	GHashTable *uid_nodemap; /* uid (from info) -> tree node mapping */
-	
-	GHashTable *normalised_hash;
 	
 	/* UID's to hide.  Keys in the mempool */
 	/* IMPORTANT: You MUST have obtained the hide lock, to operate on this data */

Attachment: smime.p7s
Description: S/MIME cryptographic signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]