summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2022-07-25 09:51:18 +0200
committerTomek <kobewi4e@gmail.com>2022-07-25 22:15:15 +0200
commit5315c9597f72555b9bb3afd915146035e393ffe8 (patch)
tree6ecefaac4c199d2bab8eadeee54331d2221001bc
parent72b5a4335e914997ef46928034e8371724b29280 (diff)
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);
}