diff options
author | Poommetee Ketson <poommetee@protonmail.com> | 2017-10-21 04:58:11 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 04:58:11 +0700 |
commit | ec12e3b4f97eeae44f0944d2817750093c7fdbe1 (patch) | |
tree | 7f67c9e6aa81f12028e403adea70402ce3c57d3a /scene/gui | |
parent | 8cb76888aefbbf2891440a5e485219a60886ac3a (diff) | |
parent | 8d8a90daef1fa70887e3229377fa4b1bde1f251b (diff) |
Merge pull request #12042 from MillionOstrich/treeitem-move-to-bottom
Stop move_to_bottom losing references to treeitems
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/tree.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 178a1c272b..931dcfed91 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -47,18 +47,21 @@ void TreeItem::move_to_top() { } void TreeItem::move_to_bottom() { - if (!parent || !next) return; - while (next) { + TreeItem *prev = get_prev(); + TreeItem *last = next; + while (last->next) + last = last->next; - if (parent->childs == this) - parent->childs = next; - TreeItem *n = next; - next = n->next; - n->next = this; + if (prev) { + prev->next = next; + } else { + parent->childs = next; } + last->next = this; + next = NULL; } Size2 TreeItem::Cell::get_icon_size() const { |