Index: thunar/thunar-tree-model.c =================================================================== --- thunar/thunar-tree-model.c (revision 28788) +++ thunar/thunar-tree-model.c (working copy) @@ -178,6 +178,12 @@ gboolean sort_case_sensitive; GNode *root; + + /* when this setting is enabled, we do not ref nodes. this is + * used to avoid a race condition when gtk traverses the tree + * and reads the iter data. See bug #2502. + */ + gboolean lock_ref_node; }; struct _ThunarTreeModelItem @@ -307,6 +313,7 @@ /* initialize the model data */ model->sort_case_sensitive = TRUE; + model->lock_ref_node = FALSE; /* connect to the file monitor */ model->file_monitor = thunar_file_monitor_get_default (); @@ -760,6 +767,10 @@ _thunar_return_if_fail (iter->user_data != NULL); _thunar_return_if_fail (iter->stamp == model->stamp); + /* leave when locked */ + if (model->lock_ref_node) + return; + /* determine the node for the iterator */ node = G_NODE (iter->user_data); if (G_UNLIKELY (node == model->root)) @@ -1699,3 +1710,13 @@ } } + + +void +thunar_tree_model_set_lock_ref_node (ThunarTreeModel *model, + gboolean lock_ref_node) +{ + _thunar_return_if_fail (THUNAR_IS_TREE_MODEL (model)); + + model->lock_ref_node = !!lock_ref_node; +} Index: thunar/thunar-tree-model.h =================================================================== --- thunar/thunar-tree-model.h (revision 28788) +++ thunar/thunar-tree-model.h (working copy) @@ -61,6 +61,9 @@ void thunar_tree_model_set_case_sensitive (ThunarTreeModel *model, gboolean case_sensitive); +void thunar_tree_model_set_lock_ref_node (ThunarTreeModel *model, + gboolean lock_ref_node); + G_END_DECLS; #endif /* !__THUNAR_TREE_MODEL_H__ */ Index: thunar/thunar-tree-view.c =================================================================== --- thunar/thunar-tree-view.c (revision 28788) +++ thunar/thunar-tree-view.c (working copy) @@ -2133,10 +2133,16 @@ /* apply the new setting */ view->show_hidden = show_hidden; + /* lock loading nodes in the tree, see bug #2505 */ + thunar_tree_model_set_lock_ref_node (THUNAR_TREE_MODEL (view->model), TRUE); + /* update the filter */ filter = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter)); + /* release the lock */ + thunar_tree_model_set_lock_ref_node (THUNAR_TREE_MODEL (view->model), FALSE); + /* notify listeners */ g_object_notify (G_OBJECT (view), "show-hidden"); }