From bb8648a2e9e9c10c69e5e7983f545413b2f6edc8 Mon Sep 17 00:00:00 2001 From: Ell Date: Sun, 21 Apr 2019 09:59:24 -0400 Subject: [PATCH] Issue #3284 - Wrong layer renamed when switching images In gimp_container_tree_view_clear_items(), temporarily unset the tree-view's model before clearing it, so that name editing is stopped beforehand. Otherwise, name editing is stopped once the corresponding item is removed from the store, causing us to rename the wrong item. --- app/widgets/gimpcontainertreeview.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c index 585b23e48b..ca44847ec6 100644 --- a/app/widgets/gimpcontainertreeview.c +++ b/app/widgets/gimpcontainertreeview.c @@ -919,15 +919,21 @@ gimp_container_tree_view_clear_items (GimpContainerView *view) { GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view); - /* GTK+ 3.x always keeps the row with the cursor selected, so we get - * a gazillion selection changed during gtk_tree_store_clear() - */ g_signal_handlers_block_by_func (tree_view->priv->selection, gimp_container_tree_view_selection_changed, tree_view); + /* temporarily unset the tree-view's model, so that name editing is stopped + * now, before clearing the tree store. otherwise, name editing would stop + * when the corresponding item is removed from the store, leading us to + * rename the wrong item. see issue #3284. + */ + gtk_tree_view_set_model (tree_view->view, NULL); + gimp_container_tree_store_clear_items (GIMP_CONTAINER_TREE_STORE (tree_view->model)); + gtk_tree_view_set_model (tree_view->view, tree_view->model); + g_signal_handlers_unblock_by_func (tree_view->priv->selection, gimp_container_tree_view_selection_changed, tree_view);