Skip to content

Commit

Permalink
Stuck tree pane makes Thunar use 100% CPU
Browse files Browse the repository at this point in the history
(bug #10161)

Followup fix of #14900
- added missing NULL checks
- added missing unref calls on ThunarFiles
- fixed logic for file-system root
  • Loading branch information
Alexander Schwinn committed Jan 16, 2019
1 parent 969e145 commit cdd2be2
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions thunar/thunar-tree-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -2501,6 +2501,8 @@ thunar_tree_view_cursor_idle (gpointer user_data)
GtkTreePath *path;
GtkTreeIter iter;
ThunarFile *file;
ThunarFile *parent;
GFileInfo *parent_info;
GtkTreeIter child_iter;
ThunarFile *file_in_tree;
gboolean done = TRUE;
Expand Down Expand Up @@ -2549,18 +2551,28 @@ THUNAR_THREADS_ENTER
break;
}

/* initialize child_iter */
/* Try to create missing children if there are none (this as well initializes child_iter if there are children) */
if (!gtk_tree_model_iter_children (GTK_TREE_MODEL (view->model), &child_iter, &iter))
{
/* E.g. folders for which we dont have read permission dont have any child in the tree */
/* Make sure that missing read permissions are the problem */
if (!g_file_info_get_attribute_boolean (thunar_file_get_info (thunar_file_get_parent (file, NULL)), G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
done = FALSE;
parent = thunar_file_get_parent (file, NULL);
if (parent == NULL) /* e.g root has no parent .. skip it */
continue;

parent_info = thunar_file_get_info (parent);
if (parent_info != NULL)
{
/* We know that there is a File. Lets just create the required tree-node */
thunar_tree_model_add_child (view->model, iter.user_data, file);
done = FALSE;
/* E.g. folders for which we do not have read permission dont have any child in the tree */
/* Make sure that missing read permissions are the problem */
if (!g_file_info_get_attribute_boolean (parent_info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
{
/* We KNOW that there is a File. Lets just create the required tree-node */
thunar_tree_model_add_child (view->model, iter.user_data, file);
}
}
break;
g_object_unref (parent);
break; /* we dont have a valid child_iter by now, so we cannot continue. */
/* Since done is FALSE, the next iteration on thunar_tree_view_cursor_idle will go deeper */
}

/* loop on children to see if any folder matches */
Expand All @@ -2585,6 +2597,13 @@ THUNAR_THREADS_ENTER
}
}

/* tidy up */
for (lp = path_as_list; lp != NULL; lp = lp->next)
{
file = THUNAR_FILE (lp->data);
if (file != NULL && file != view->current_directory)
g_object_unref (file);
}
g_list_free (path_as_list);

THUNAR_THREADS_LEAVE
Expand Down

0 comments on commit cdd2be2

Please sign in to comment.