Index: mail/mail-component.c
===================================================================
--- mail/mail-component.c	(revision 33979)
+++ mail/mail-component.c	(working copy)
@@ -652,30 +652,33 @@ enable_folder_tree (GtkWidget *emfb, Gtk
 {
 	char *uri;
 	CamelURL *selected_curl, *current_curl;
-	CamelFolder *folder;
-	CamelException ex;
 	EMFolderView *emfv = (EMFolderView *)emfb;
 
 	/* Currently displayed folder */
-	MessageList *ml = emfv->list;
-	folder = ml->folder;
-	uri = mail_tools_folder_to_url (folder);
-	current_curl = camel_url_new (uri, NULL);
+	uri = mail_tools_folder_to_url (emfv->list->folder);
+	current_curl = uri ? camel_url_new (uri, NULL) : NULL;
+	g_free (uri);
 
-	/* Selected folder in emft*/
+	/* Selected folder in emft */
 	uri = em_folder_tree_get_selected_uri ((EMFolderTree *) emft);
-	folder = mail_tool_uri_to_folder (uri, 0, &ex);
-	selected_curl = camel_url_new (uri, NULL);
+	selected_curl = uri ? camel_url_new (uri, NULL) : NULL;
 
-	if (!camel_url_equal (selected_curl, current_curl)) 
- 		g_signal_emit_by_name (emft, "folder-selected", emft, uri, folder->full_name, uri, folder->folder_flags); 
+	if (current_curl && selected_curl && !camel_url_equal (selected_curl, current_curl)) {
+		CamelFolder *folder;
+		CamelException ex;
+
+		camel_exception_init (&ex);
+		folder = mail_tool_uri_to_folder (uri, 0, &ex);
+ 		g_signal_emit_by_name (
+			emft, "folder-selected", emft, uri,
+			folder->full_name, uri, folder->folder_flags);
+	}
 
 	gtk_widget_set_sensitive (emft, TRUE);
 
 	camel_url_free (current_curl);
 	camel_url_free (selected_curl);
 	g_free (uri);
-
 }
 
 /* Evolution::Component CORBA methods.  */
