From b79cac6d2d1abbd08181e2dd2668be0c7f66237f Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Tue, 14 Nov 2023 11:27:07 +0800 Subject: [PATCH] Make Tree's set_selected check if treeitem belongs to the tree --- scene/gui/tree.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index a4c239cf534..1d06ce05ae9 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -4544,6 +4544,8 @@ TreeItem *Tree::get_selected() const { void Tree::set_selected(TreeItem *p_item, int p_column) { ERR_FAIL_INDEX(p_column, columns.size()); ERR_FAIL_NULL(p_item); + ERR_FAIL_COND_MSG(p_item->get_tree() != this, "The provided TreeItem does not belong to this Tree. Ensure that the TreeItem is a part of the Tree before setting it as selected."); + select_single_item(p_item, get_root(), p_column); }