[evolution] Bug #639698 - Crash in mail_shell_view_execute_search()



commit fe8e579347a081c6b4bba79430b8c95054bf1280
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jan 23 15:24:09 2013 +0100

    Bug #639698 - Crash in mail_shell_view_execute_search()

 modules/mail/e-mail-shell-view.c |   48 ++++++++++++++++++++++---------------
 1 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 548be0b..f739ca6 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -545,8 +545,8 @@ all_accounts:
 	 * account-wide searches still in progress. */
 	text = e_shell_searchbar_get_search_text (searchbar);
 	if (text == NULL || *text == '\0') {
-		CamelStore *selected_store;
-		gchar *selected_folder_name;
+		CamelStore *selected_store = NULL;
+		gchar *selected_folder_name = NULL;
 
 		if (priv->search_account_all != NULL) {
 			g_object_unref (priv->search_account_all);
@@ -564,13 +564,17 @@ all_accounts:
 		 * avoid search conflicts, so we can't just grab the
 		 * folder URI and let the asynchronous callbacks run
 		 * after we've already kicked off the search. */
-		em_folder_tree_get_selected (
-			folder_tree, &selected_store, &selected_folder_name);
-		folder = camel_store_get_folder_sync (
-			selected_store, selected_folder_name,
-			CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL);
-		e_mail_reader_set_folder (reader, folder);
-		g_object_unref (selected_store);
+		if (em_folder_tree_get_selected (folder_tree, &selected_store, &selected_folder_name) &&
+		    selected_store && selected_folder_name) {
+			folder = camel_store_get_folder_sync (
+				selected_store, selected_folder_name,
+				CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL);
+			e_mail_reader_set_folder (reader, folder);
+			g_object_unref (folder);
+		}
+
+		if (selected_store)
+			g_object_unref (selected_store);
 		g_free (selected_folder_name);
 
 		gtk_widget_set_sensitive (GTK_WIDGET (combo_box), TRUE);
@@ -609,7 +613,7 @@ all_accounts:
 	camel_service_connect_sync (service, NULL, NULL);
 
 	search_folder = (CamelVeeFolder *) camel_vee_folder_new (
-		CAMEL_STORE (service), _("All Account Search"), 0);
+		CAMEL_STORE (service), _("All Account Search"), CAMEL_STORE_FOLDER_PRIVATE);
 	priv->search_account_all = search_folder;
 
 	g_object_unref (service);
@@ -642,8 +646,8 @@ current_account:
 	 * account-wide searches still in progress. */
 	text = e_shell_searchbar_get_search_text (searchbar);
 	if (text == NULL || *text == '\0') {
-		CamelStore *selected_store;
-		gchar *selected_folder_name;
+		CamelStore *selected_store = NULL;
+		gchar *selected_folder_name = NULL;
 
 		if (priv->search_account_current != NULL) {
 			g_object_unref (priv->search_account_current);
@@ -661,13 +665,17 @@ current_account:
 		 * avoid search conflicts, so we can't just grab the
 		 * folder URI and let the asynchronous callbacks run
 		 * after we've already kicked off the search. */
-		em_folder_tree_get_selected (
-			folder_tree, &selected_store, &selected_folder_name);
-		folder = camel_store_get_folder_sync (
-			selected_store, selected_folder_name,
-			CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL);
-		e_mail_reader_set_folder (reader, folder);
-		g_object_unref (selected_store);
+		if (em_folder_tree_get_selected (folder_tree, &selected_store, &selected_folder_name) &&
+		    selected_store && selected_folder_name) {
+			folder = camel_store_get_folder_sync (
+				selected_store, selected_folder_name,
+				CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL);
+			e_mail_reader_set_folder (reader, folder);
+			g_object_unref (folder);
+		}
+
+		if (selected_store)
+			g_object_unref (selected_store);
 		g_free (selected_folder_name);
 
 		gtk_widget_set_sensitive (GTK_WIDGET (combo_box), TRUE);
@@ -706,7 +714,7 @@ current_account:
 	camel_service_connect_sync (service, NULL, NULL);
 
 	search_folder = (CamelVeeFolder *) camel_vee_folder_new (
-		CAMEL_STORE (service), _("Account Search"), 0);
+		CAMEL_STORE (service), _("Account Search"), CAMEL_STORE_FOLDER_PRIVATE);
 	priv->search_account_current = search_folder;
 
 	g_object_unref (service);



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