[evolution] Bug #588787 - Crash on search in an active account or all accounts



commit a5fd4e8ffc0dadb6f62d8e670ac83c213c89b7f1
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jul 21 18:49:32 2009 +0200

    Bug #588787 - Crash on search in an active account or all accounts

 mail/em-folder-browser.c |   29 +++++++++++++++++++++--------
 mail/mail-component.c    |    7 +++++--
 2 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index 0574de0..66f76c6 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -1011,7 +1011,6 @@ struct _setup_msg {
 
 	CamelFolder *folder;
 	CamelOperation *cancel;
-	gchar *query;
 	GList *sources_uri;
 	GList *sources_folder;
 };
@@ -1033,8 +1032,6 @@ vfolder_setup_exec(struct _setup_msg *m)
 
 	d(printf("Setting up Search Folder: %s\n", m->folder->full_name));
 
-	camel_vee_folder_set_expression((CamelVeeFolder *)m->folder, m->query);
-
 	l = m->sources_uri;
 	while (l) {
 		d(printf(" Adding uri: %s\n", (gchar *)l->data));
@@ -1077,7 +1074,6 @@ vfolder_setup_free (struct _setup_msg *m)
 	GList *l;
 
 	camel_object_unref(m->folder);
-	g_free(m->query);
 
 	l = m->sources_uri;
 	while (l) {
@@ -1104,7 +1100,7 @@ static MailMsgInfo vfolder_setup_info = {
 
 /* sources_uri should be camel uri's */
 static gint
-vfolder_setup(CamelFolder *folder, const gchar *query, GList *sources_uri, GList *sources_folder, CamelOperation *cancel)
+vfolder_setup (CamelFolder *folder, GList *sources_uri, GList *sources_folder, CamelOperation *cancel)
 {
 	struct _setup_msg *m;
 	gint id;
@@ -1112,7 +1108,6 @@ vfolder_setup(CamelFolder *folder, const gchar *query, GList *sources_uri, GList
 	m = mail_msg_new(&vfolder_setup_info);
 	m->folder = folder;
 	camel_object_ref(folder);
-	m->query = g_strdup(query);
 	m->sources_uri = sources_uri;
 	m->sources_folder = sources_folder;
 
@@ -1199,14 +1194,23 @@ emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
 			    efb->account_search_vf = (CamelVeeFolder *)camel_vee_folder_new (vfolder_store,_("Account Search"),CAMEL_STORE_VEE_FOLDER_AUTO);
 
 			    /* Set the search expression  */
+			    camel_vee_folder_set_expression (efb->account_search_vf, search_word);
+
 			    efb->account_search_cancel = camel_operation_new (NULL, NULL);
-			    vfolder_setup ((CamelFolder *)efb->account_search_vf, search_word, NULL, folder_list_account, efb->account_search_cancel);
+			    vfolder_setup ((CamelFolder *)efb->account_search_vf, NULL, folder_list_account, efb->account_search_cancel);
 
 			    folder_uri = mail_tools_folder_to_url ((CamelFolder *)efb->account_search_vf);
 			    emfb_set_search_folder (emfv, (CamelFolder *)efb->account_search_vf, folder_uri);
 			    g_free (folder_uri);
 			    g_free (storeuri);
 		    } else {
+			    /* cancel previous filling first, if under way */
+			    if (efb->account_search_cancel) {
+				    camel_operation_cancel (efb->account_search_cancel);
+				    camel_operation_unref (efb->account_search_cancel);
+				    efb->account_search_cancel = NULL;
+			    }
+
 			    /* Reuse the existing search folder */
 			    camel_vee_folder_set_expression((CamelVeeFolder *)efb->account_search_vf, search_word);
 		    }
@@ -1281,8 +1285,10 @@ emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
 				    l = l->next;
 			    }
 
+    			    camel_vee_folder_set_expression (efb->all_account_search_vf, search_word);
+
 			    efb->account_search_cancel = camel_operation_new (NULL, NULL);
-			    vfolder_setup ((CamelFolder *)efb->all_account_search_vf, search_word, NULL, folder_list, efb->account_search_cancel);
+			    vfolder_setup ((CamelFolder *)efb->all_account_search_vf, NULL, folder_list, efb->account_search_cancel);
 
 			    folder_uri = mail_tools_folder_to_url ((CamelFolder *)efb->all_account_search_vf);
 
@@ -1290,6 +1296,13 @@ emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
 			    g_free (folder_uri);
 			    g_free (storeuri);
 		    } else {
+			    /* cancel previous filling first, if under way */
+			    if (efb->account_search_cancel) {
+				    camel_operation_cancel (efb->account_search_cancel);
+				    camel_operation_unref (efb->account_search_cancel);
+				    efb->account_search_cancel = NULL;
+			    }
+
 			    /* Reuse the existing search folder */
 			    camel_vee_folder_set_expression((CamelVeeFolder *)efb->all_account_search_vf, search_word);
 		    }
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 1ad7d4d..4e19002 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -713,7 +713,10 @@ enable_folder_tree (GtkWidget *emfb, GtkWidget *emft)
 
 	/* Get the selected folder in the folder tree. */
 	selected_folder = em_folder_tree_get_selected_folder(EM_FOLDER_TREE (emft));
-	uri = mail_tools_folder_to_url (selected_folder);
+	if (selected_folder)
+		uri = mail_tools_folder_to_url (selected_folder);
+	else
+		uri = NULL;
 
 	selected_curl = uri ? camel_url_new (uri, NULL) : NULL;
 
@@ -1628,7 +1631,7 @@ mail_component_show_logger (gpointer top)
 void
 mail_component_show_status_bar (gboolean show)
 {
-	MailComponent *mc = mail_component_peek ();
+	/*MailComponent *mc = mail_component_peek ();*/
 
 	/* Nothing to do */
 	return;



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