diff options
author | MillionOstrich <31486600+MillionOstrich@users.noreply.github.com> | 2017-10-11 21:30:46 +0100 |
---|---|---|
committer | MillionOstrich <31486600+MillionOstrich@users.noreply.github.com> | 2017-10-11 21:35:56 +0100 |
commit | 8d8a90daef1fa70887e3229377fa4b1bde1f251b (patch) | |
tree | cdda6ef223fbd2aaa4db7588487a29acb5bb6342 | |
parent | 409e58e67abde4e7af6e43b32c23338e119377fb (diff) |
Stop move_to_bottom losing references to treeitems
-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 { |