summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-07-26 07:45:37 +0200
committerGitHub <noreply@github.com>2022-07-26 07:45:37 +0200
commitf2f1f079f06d761b13b38f6c1a0904b9a273ae52 (patch)
tree21144aebb2d1e9da04cf11b0222609a8997958b6
parente67b323c39bb8e34158cf89bef94c285e0d9705c (diff)
parent5315c9597f72555b9bb3afd915146035e393ffe8 (diff)
Merge pull request #63427 from KoBeWi/metIeerT
Fix negative indices in TreeItem
-rw-r--r--scene/gui/tree.cpp5
1 files changed, 5 insertions, 0 deletions
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);
}