From 5315c9597f72555b9bb3afd915146035e393ffe8 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 25 Jul 2022 09:51:18 +0200 Subject: Fix negative indices in TreeItem --- scene/gui/tree.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 2c4cba4954..f08b8e4669 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -723,7 +723,12 @@ TreeItem *TreeItem::get_next_visible(bool p_wrap) { TreeItem *TreeItem::get_child(int p_idx) { _create_children_cache(); + + if (p_idx < 0) { + p_idx += children_cache.size(); + } ERR_FAIL_INDEX_V(p_idx, children_cache.size(), nullptr); + return children_cache.get(p_idx); } -- cgit v1.2.3