From f7c1c83daac981fecff592bc9cdd80065e979a4a Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Tue, 27 Feb 2024 16:34:15 +0100 Subject: [PATCH] Fix crash when selecting re-added `Tree` item --- scene/gui/tree.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index bf456cd0485..ea6dbebd3bd 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -120,6 +120,10 @@ void TreeItem::_change_tree(Tree *p_tree) { } if (tree->selected_item == this) { + for (int i = 0; i < tree->selected_item->cells.size(); i++) { + tree->selected_item->cells.write[i].selected = false; + } + tree->selected_item = nullptr; }