Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3445
diff -u -3 -r1.3445 ChangeLog
--- mail/ChangeLog	30 Aug 2004 04:23:21 -0000	1.3445
+++ mail/ChangeLog	30 Aug 2004 05:46:52 -0000
@@ -1,3 +1,27 @@
+2004-08-30  Not Zed  <NotZed@Ximian.com>
+
+	** See bug #64377.
+
+	* em-folder-selector.c (emfs_response): only set the uri if we
+	have one to set.
+
+	* em-folder-tree.c (em_folder_tree_finalize): Removed
+	cose using selected_path and selected_uri strings.
+	(emft_popup_new_folder): "
+	(emft_popup_copy_folder_selected): "
+	(emft_tree_selection_changed): 
+	(emft_tree_row_activated): ", free paths after use.
+
+	* em-folder-selector.c (emfs_create_name_changed): free
+	get_selected_uri return.
+	(emfs_create_name_activate): "
+	(em_folder_selector_get_selected_path): handle api change, store
+	the selected_path too.
+
+	* em-folder-tree.c (em_folder_tree_get_selected_uri):
+	de-constify,and get the selection directly from the tree.
+	(em_folder_tree_get_selected_path): same.
+
 2004-08-27  Not Zed  <NotZed@Ximian.com>
 
 	** See bug #63456.
Index: mail/em-folder-selector.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-selector.c,v
retrieving revision 1.30
diff -u -3 -r1.30 em-folder-selector.c
--- mail/em-folder-selector.c	25 Jun 2004 14:44:49 -0000	1.30
+++ mail/em-folder-selector.c	30 Aug 2004 05:46:53 -0000
@@ -166,7 +166,8 @@
 	dialog = em_folder_selector_create_new (emft, 0, _("Create New Folder"), _("Specify where to create the folder:"));
 	gtk_window_set_transient_for ((GtkWindow *) dialog, (GtkWindow *) emfs);
 	uri = em_folder_selector_get_selected_uri (emfs);
-	em_folder_tree_set_selected (emft, uri);
+	if (uri)
+		em_folder_tree_set_selected (emft, uri);
 	
 	if (gtk_dialog_run ((GtkDialog *) dialog) == GTK_RESPONSE_OK) {
 		uri = em_folder_selector_get_selected_uri ((EMFolderSelector *) dialog);
@@ -189,16 +190,17 @@
 static void
 emfs_create_name_changed (GtkEntry *entry, EMFolderSelector *emfs)
 {
-	const char *path, *text = NULL;
+	char *path;
+	const char *text = NULL;
 	gboolean active;
 	
 	if (emfs->name_entry->text_length > 0)
 		text = gtk_entry_get_text (emfs->name_entry);
 	
 	path = em_folder_tree_get_selected_uri(emfs->emft);
-
 	active = text && path && !strchr (text, '/');
-	
+	g_free(path);
+
 	gtk_dialog_set_response_sensitive ((GtkDialog *) emfs, GTK_RESPONSE_OK, active);
 }
 
@@ -276,13 +278,15 @@
 emfs_create_name_activate (GtkEntry *entry, EMFolderSelector *emfs)
 {
 	if (emfs->name_entry->text_length > 0) {
-		const char *path, *text;
+		char *path;
+		const char *text;
 		
 		text = gtk_entry_get_text (emfs->name_entry);
 		path = em_folder_tree_get_selected_uri(emfs->emft);
 		
 		if (text && path && !strchr (text, '/'))
 			g_signal_emit_by_name (emfs, "response", GTK_RESPONSE_OK);
+		g_free(path);
 	}
 }
 
@@ -333,7 +337,8 @@
 const char *
 em_folder_selector_get_selected_uri (EMFolderSelector *emfs)
 {
-	const char *uri, *name;
+	char *uri;
+	const char *name;
 	
 	if (!(uri = em_folder_tree_get_selected_uri (emfs->emft))) {
 		d(printf ("no selected folder?\n"));
@@ -397,32 +402,36 @@
 const char *
 em_folder_selector_get_selected_path (EMFolderSelector *emfs)
 {
-	const char *path;
+	char *uri, *path;
 	
 	if (emfs->selected_path) {
 		/* already did the work in a previous call */
 		return emfs->selected_path;
 	}
 
-	if (!em_folder_tree_get_selected_uri(emfs->emft)) {
+	if ((uri = em_folder_tree_get_selected_uri(emfs->emft)) == NULL) {
 		d(printf ("no selected folder?\n"));
 		return NULL;
 	}
+	g_free(uri);
 
 	path = em_folder_tree_get_selected_path(emfs->emft);
-	path = path?path:"";
 	if (emfs->name_entry) {
 		const char *name;
 		char *newpath;
 		
 		name = gtk_entry_get_text (emfs->name_entry);
 		if (strcmp (path, "") != 0)
-			newpath = g_strdup_printf ("%s/%s", path, name);
+			newpath = g_strdup_printf ("%s/%s", path?path:"", name);
 		else
 			newpath = g_strdup (name);
 		
-		path = emfs->selected_path = newpath;
+		g_free(path);
+		emfs->selected_path = newpath;
+	} else {
+		g_free(emfs->selected_path);
+		emfs->selected_path = path?path:g_strdup("");
 	}
-	
-	return path;
+
+	return emfs->selected_path;
 }
Index: mail/em-folder-tree.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree.c,v
retrieving revision 1.125
diff -u -3 -r1.125 em-folder-tree.c
--- mail/em-folder-tree.c	26 Aug 2004 15:05:48 -0000	1.125
+++ mail/em-folder-tree.c	30 Aug 2004 05:46:59 -0000
@@ -86,9 +86,6 @@
 	GSList *select_uris;	/* selected_uri structures of each path pending selection. */
 	GHashTable *select_uris_table; /*Removed as they're encountered, so use this to find uri's not presnet but selected */
 	
-	char *selected_uri;
-	char *selected_path;
-
 	guint32 excluded;
 
 	int do_multiselect:1;	/* multiple select mode */
@@ -378,8 +375,6 @@
 	
 	priv = g_new0 (struct _EMFolderTreePrivate, 1);
 	priv->select_uris_table = g_hash_table_new(g_str_hash, g_str_equal);
-	priv->selected_uri = NULL;
-	priv->selected_path = NULL;
 	priv->treeview = NULL;
 	priv->model = NULL;
 	priv->drag_row = NULL;
@@ -399,8 +394,6 @@
 		emft->priv->select_uris = NULL;
 	}
 
-	g_free (emft->priv->selected_uri);
-	g_free (emft->priv->selected_path);
 	g_free (emft->priv);
 	
 	G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -1933,14 +1926,11 @@
 
 	emft_clear_selected_list(emft);
 	
-	g_free (priv->selected_uri);
-	priv->selected_uri = uri;
-	
-	g_free (priv->selected_path);
-	priv->selected_path = full_name;
-	
 	g_signal_emit (emft, signals[FOLDER_SELECTED], 0, full_name, uri, flags);
 	g_signal_emit (emft, signals[FOLDER_ACTIVATED], 0, full_name, uri);
+
+	g_free(full_name);
+	g_free(uri);
 }
 
 #if 0
@@ -2141,7 +2131,7 @@
 	struct _copy_folder_data *cfd = data;
 	struct _EMFolderTreePrivate *priv;
 	CamelStore *fromstore = NULL, *tostore = NULL;
-	char *tobase = NULL, *frombase;
+	char *tobase = NULL, *frombase = NULL, *fromuri = NULL;
 	CamelException ex;
 	CamelURL *url;
 
@@ -2155,9 +2145,13 @@
 	d(printf ("%sing folder '%s' to '%s'\n", cfd->delete ? "move" : "copy", priv->selected_path, uri));
 	
 	camel_exception_init (&ex);
-	frombase = priv->selected_path;
-	
-	if (!(fromstore = camel_session_get_store (session, priv->selected_uri, &ex))) {
+
+	fromuri = em_folder_tree_get_selected_uri(cfd->emft);
+	g_return_if_fail(fromuri != NULL);
+	frombase = em_folder_tree_get_selected_path(cfd->emft);
+	g_return_if_fail(frombase != NULL);
+
+	if (!(fromstore = camel_session_get_store (session, fromuri, &ex))) {
 		e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *) cfd->emft),
 			    cfd->delete?"mail:no-move-folder-notexist":"mail:no-copy-folder-notexist", frombase, uri, ex.desc, NULL);
 		goto fail;
@@ -2191,6 +2185,8 @@
 		camel_object_unref(fromstore);
 	if (tostore)
 		camel_object_unref(tostore);
+	g_free(frombase);
+	g_free(fromuri);
 	camel_exception_clear (&ex);
 	g_free (cfd);
 }
@@ -2427,11 +2423,14 @@
 {
 	EMFolderTree *folder_tree;
 	GtkWidget *dialog;
-	
+	char *uri;
+
 	folder_tree = (EMFolderTree *) em_folder_tree_new_with_model (emft->priv->model);
 	
 	dialog = em_folder_selector_create_new (folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));
-	em_folder_selector_set_selected ((EMFolderSelector *) dialog, emft->priv->selected_uri);
+	uri = em_folder_tree_get_selected_uri(emft);
+	em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri);
+	g_free(uri);
 	g_signal_connect (dialog, "response", G_CALLBACK (emft_popup_new_folder_response), emft);
 	gtk_widget_show (dialog);
 }
@@ -2840,7 +2839,6 @@
 static void
 emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft)
 {
-	struct _EMFolderTreePrivate *priv = emft->priv;
 	char *full_name, *uri;
 	GtkTreeModel *model;
 	GtkTreeIter iter;
@@ -2852,16 +2850,11 @@
 	gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &full_name,
 			    COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1);
 
-	g_free (priv->selected_uri);
-	priv->selected_uri = uri;
-	
-	g_free (priv->selected_path);
-	priv->selected_path = full_name;
-	
 	g_signal_emit (emft, signals[FOLDER_SELECTED], 0, full_name, uri, flags);
+	g_free(uri);
+	g_free(full_name);
 }
 
-
 void
 em_folder_tree_set_selected (EMFolderTree *emft, const char *uri)
 {
@@ -2873,23 +2866,39 @@
 	g_list_free(l);
 }
 
-const char *
+char *
 em_folder_tree_get_selected_uri (EMFolderTree *emft)
 {
+	GtkTreeSelection *selection;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	char *uri = NULL;
+
 	g_return_val_if_fail (EM_IS_FOLDER_TREE (emft), NULL);
+
+	selection = gtk_tree_view_get_selection(emft->priv->treeview);
+	if (gtk_tree_selection_get_selected(selection, &model, &iter))
+		gtk_tree_model_get(model, &iter, COL_STRING_URI, &uri, -1);
 	
-	return emft->priv->selected_uri;
+	return uri;
 }
 
-
-const char *
+char *
 em_folder_tree_get_selected_path (EMFolderTree *emft)
 {
+	GtkTreeSelection *selection;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	char *name = NULL;
+
 	g_return_val_if_fail (EM_IS_FOLDER_TREE (emft), NULL);
+
+	selection = gtk_tree_view_get_selection(emft->priv->treeview);
+	if (gtk_tree_selection_get_selected(selection, &model, &iter))
+		gtk_tree_model_get(model, &iter, COL_STRING_FULL_NAME, &name, -1);
 	
-	return emft->priv->selected_path;
+	return name;
 }
-
 
 EMFolderTreeModel *
 em_folder_tree_get_model (EMFolderTree *emft)
Index: mail/em-folder-tree.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree.h,v
retrieving revision 1.11
diff -u -3 -r1.11 em-folder-tree.h
--- mail/em-folder-tree.h	25 Jun 2004 14:44:49 -0000	1.11
+++ mail/em-folder-tree.h	30 Aug 2004 05:47:00 -0000
@@ -80,8 +80,8 @@
 GList *em_folder_tree_get_selected_paths (EMFolderTree *emft);
 
 void em_folder_tree_set_selected (EMFolderTree *emft, const char *uri);
-const char *em_folder_tree_get_selected_uri (EMFolderTree *emft);
-const char *em_folder_tree_get_selected_path (EMFolderTree *emft);
+char *em_folder_tree_get_selected_uri (EMFolderTree *emft);
+char *em_folder_tree_get_selected_path (EMFolderTree *emft);
 
 EMFolderTreeModel *em_folder_tree_get_model (EMFolderTree *emft);
 
