From 42bfa0dc3be571cf8677ac350d115528597f899b Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Tue, 2 Oct 2018 22:05:52 +0200 Subject: Crash in tree-view when multiple windows are open (Bug #14714) --- thunar/thunar-tree-model.c | 38 -------------------------------------- thunar/thunar-tree-model.h | 2 -- thunar/thunar-tree-view.c | 11 ++++++++--- 3 files changed, 8 insertions(+), 43 deletions(-) diff --git a/thunar/thunar-tree-model.c b/thunar/thunar-tree-model.c index df06fd35..9eb652ff 100644 --- a/thunar/thunar-tree-model.c +++ b/thunar/thunar-tree-model.c @@ -1777,44 +1777,6 @@ thunar_tree_model_node_traverse_visible (GNode *node, -/** - * thunar_tree_model_get_default: - * - * Returns the default, shared #ThunarTreeModel instance. - * - * The caller is responsible to free the returned instance - * using g_object_unref() when no longer needed. - * - * Return value: a reference to the default #ThunarTreeModel. - **/ -ThunarTreeModel* -thunar_tree_model_get_default (void) -{ - static ThunarTreeModel *model = NULL; - ThunarPreferences *preferences; - - if (G_LIKELY (model == NULL)) - { - /* allocate the shared model on-demand */ - model = g_object_new (THUNAR_TYPE_TREE_MODEL, NULL); - g_object_add_weak_pointer (G_OBJECT (model), (gpointer) &model); - - /* synchronize the the global "misc-case-sensitive" preference */ - preferences = thunar_preferences_get (); - g_object_set_data_full (G_OBJECT (model), I_("thunar-preferences"), preferences, g_object_unref); - exo_binding_new (G_OBJECT (preferences), "misc-case-sensitive", G_OBJECT (model), "case-sensitive"); - } - else - { - /* take a reference for the caller */ - g_object_ref (G_OBJECT (model)); - } - - return model; -} - - - /** * thunar_tree_model_get_case_sensitive: * @model : a #ThunarTreeModel. diff --git a/thunar/thunar-tree-model.h b/thunar/thunar-tree-model.h index 5c7f5f31..0bc0cf26 100644 --- a/thunar/thunar-tree-model.h +++ b/thunar/thunar-tree-model.h @@ -59,8 +59,6 @@ typedef enum GType thunar_tree_model_get_type (void) G_GNUC_CONST; -ThunarTreeModel *thunar_tree_model_get_default (void); - void thunar_tree_model_set_visible_func (ThunarTreeModel *model, ThunarTreeModelVisibleFunc func, gpointer data); diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c index 2c1e0685..7a611726 100644 --- a/thunar/thunar-tree-view.c +++ b/thunar/thunar-tree-view.c @@ -392,8 +392,13 @@ thunar_tree_view_init (ThunarTreeView *view) view->preferences = thunar_preferences_get (); g_signal_connect_swapped (G_OBJECT (view->preferences), "notify::tree-icon-emblems", G_CALLBACK (gtk_widget_queue_draw), view); - /* connect to the default tree model */ - view->model = thunar_tree_model_get_default (); + /* Create a tree model for this tree view */ + view->model = g_object_new (THUNAR_TYPE_TREE_MODEL, NULL); + + /* synchronize the the global "misc-case-sensitive" preference */ + g_object_set_data_full (G_OBJECT (view->model), I_("thunar-preferences"), view->preferences, g_object_unref); + exo_binding_new (G_OBJECT (view->preferences), "misc-case-sensitive", G_OBJECT (view->model), "case-sensitive"); + thunar_tree_model_set_visible_func (view->model, thunar_tree_view_visible_func, view); gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->model)); @@ -487,7 +492,7 @@ thunar_tree_view_finalize (GObject *object) /* release our reference on the preferences */ g_object_unref (G_OBJECT (view->preferences)); - /* disconnect from the default tree model */ + /* free the tree model */ g_object_unref (G_OBJECT (view->model)); /* drop any existing "new-files" closure */ -- cgit v1.2.1