diff options
author | kobewi <kobewi4e@gmail.com> | 2022-07-25 09:51:18 +0200 |
---|---|---|
committer | Tomek <kobewi4e@gmail.com> | 2022-07-25 22:15:15 +0200 |
commit | 5315c9597f72555b9bb3afd915146035e393ffe8 (patch) | |
tree | 6ecefaac4c199d2bab8eadeee54331d2221001bc | |
parent | 72b5a4335e914997ef46928034e8371724b29280 (diff) |
Fix negative indices in TreeItem
-rw-r--r-- | scene/gui/tree.cpp | 5 |
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); } |