changeset 2002:91b066c12e44

do not use FileData entries with empty path
author Vladimir Nadvornik <nadvornik@suse.cz>
date Fri, 30 Sep 2011 10:54:32 +0200
parents 8502ca70bb53
children a3b90197b9ac
files src/view_dir_tree.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/view_dir_tree.c	Mon May 10 11:33:13 2010 +0000
+++ b/src/view_dir_tree.c	Fri Sep 30 10:54:32 2011 +0200
@@ -159,7 +159,7 @@
 {
 	if (!nd) return;
 
-	file_data_unref(nd->fd);
+	if (nd->fd) file_data_unref(nd->fd);
 	g_free(nd);
 }
 
@@ -281,7 +281,7 @@
 			NodeData *nd;
 
 			gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
-			if (strcmp(nd->fd->name, pd->name) == 0)
+			if (nd->fd && strcmp(nd->fd->name, pd->name) == 0)
 				{
 				fd = nd->fd;
 				}
@@ -419,7 +419,7 @@
 	/* all nodes are created with an "empty" node, so that the expander is shown
 	 * this is removed when the child is populated */
 	end = g_new0(NodeData, 1);
-	end->fd = file_data_new_simple("");
+	end->fd = NULL;
 	end->expanded = TRUE;
 
 	gtk_tree_store_append(store, &empty, &child);
@@ -462,7 +462,7 @@
 
 	if (nd->expanded)
 		{
-		if (!isdir(nd->fd->path))
+		if (!nd->fd || !isdir(nd->fd->path))
 			{
 			if (vd->click_fd == nd->fd) vd->click_fd = NULL;
 			if (vd->drop_fd == nd->fd) vd->drop_fd = NULL;
@@ -904,6 +904,10 @@
 	gtk_tree_model_get(store, a, DIR_COLUMN_POINTER, &nda, -1);
 	gtk_tree_model_get(store, b, DIR_COLUMN_POINTER, &ndb, -1);
 
+	if (!nda->fd && !ndb->fd) return 0;
+	if (!nda->fd) return 1;
+	if (!ndb->fd) return -1;
+
 	if (options->file_sort.case_sensitive)
 		return strcmp(nda->fd->collate_key_name, ndb->fd->collate_key_name);
 	else