From c1630f0e60cb96d50dbc95598624090eae994788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 25 Jul 2017 05:11:00 +0200 Subject: [PATCH] Fix Node::move_child() crash if moving to the end plus one (cherry picked from commit 6c1b7fd899f72136a1cc17eb9ae81746d8d98572) --- scene/main/node.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 4345bc564ee..72effe2bac5 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -274,6 +274,11 @@ void Node::move_child(Node *p_child, int p_pos) { ERR_FAIL_COND(data.blocked > 0); } + // Specifying one place beyond the end + // means the same as moving to the last position + if (p_pos == data.children.size()) + p_pos--; + data.children.remove(p_child->data.pos); data.children.insert(p_pos, p_child);