Skip to content

Commit

Permalink
do not use FileData entries with empty path
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Sep 30, 2011
1 parent 559683d commit 7bb3871
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/view_dir_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void vdtree_node_free(NodeData *nd)
{
if (!nd) return;

file_data_unref(nd->fd);
if (nd->fd) file_data_unref(nd->fd);
g_free(nd);
}

Expand Down Expand Up @@ -281,7 +281,7 @@ static GList *parts_list_add_node_points(ViewDir *vd, GList *list)
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;
}
Expand Down Expand Up @@ -419,7 +419,7 @@ static void vdtree_add_by_data(ViewDir *vd, FileData *fd, GtkTreeIter *parent)
/* 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);
Expand Down Expand Up @@ -462,7 +462,7 @@ gboolean vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gboolean f

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;
Expand Down Expand Up @@ -904,6 +904,10 @@ static gint vdtree_sort_cb(GtkTreeModel *store, GtkTreeIter *a, GtkTreeIter *b,
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
Expand Down

0 comments on commit 7bb3871

Please sign in to comment.