[evolution] Bug #629266 - Crash on search in Current Account



commit a28f6db7fcf20a618675d26bbd7072164b9d4c8c
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 29 11:02:35 2010 +0200

    Bug #629266 - Crash on search in Current Account

 modules/mail/e-mail-shell-view.c |   61 +++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 7 deletions(-)
---
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index b95153e..4d0bb6a 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -665,18 +665,65 @@ current_account:
 
 	/* Create a new search folder. */
 
-	store = camel_folder_get_parent_store (folder);
+	if (folder) {
+		store = camel_folder_get_parent_store (folder);
+	} else {
+		GtkTreeView *tree_view;
+		GtkTreeSelection *selection;
+		GtkTreeModel *model;
+		GtkTreeIter iter;
+	
+		store = NULL;
+		tree_view = GTK_TREE_VIEW (folder_tree);
+		selection = gtk_tree_view_get_selection (tree_view);
+
+		if (gtk_tree_selection_get_selected (selection, &model, &iter))
+			gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, -1);
+	}
+
 	list = NULL;  /* list of CamelFolders */
 
-	if (store->folders != NULL) {
-		GPtrArray *array;
-		guint ii;
+	if (store) {
+		CamelFolderInfo *root, *fi;
+
+		root = camel_store_get_folder_info_sync (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE, NULL, NULL);
+		fi = root;
+		while (fi) {
+			CamelFolderInfo *next;
+
+			if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0) {
+				CamelFolder *fldr;
+
+				fldr = camel_store_get_folder_sync (store, fi->full_name, 0, NULL, NULL);
+				if (fldr)
+					list = g_list_prepend (list, fldr);
+			}
+
+			/* pick the next */
+			next = fi->child;
+			if (!next)
+				next = fi->next;
+			if (!next) {
+				next = fi->parent;
+				while (next) {
+					if (next->next) {
+						next = next->next;
+						break;
+					}
+
+					next = next->parent;
+				}
+			}
 
-		array = camel_object_bag_list (store->folders);
-		for (ii = 0; ii < array->len; ii++)
-			list = g_list_append (list, array->pdata[ii]);
+			fi = next;
+		}
+
+		if (root)
+			camel_store_free_folder_info_full (store, root);
 	}
 
+	list = g_list_reverse (list);
+
 	/* FIXME Using data_dir like this is not portable. */
 	uri = g_strdup_printf ("vfolder:%s/vfolder", data_dir);
 	store = camel_session_get_store (session, uri, NULL);



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