summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-07-25 08:12:21 +0200
committerGitHub <noreply@github.com>2017-07-25 08:12:21 +0200
commit5a251d0d5c98e54659dd51aff9e5cd4298015214 (patch)
tree4efdcb49b03f81f415b366365a7961e83c5d1b87
parentf981829749e6d44569068776b47cd87012604b97 (diff)
parent6c1b7fd899f72136a1cc17eb9ae81746d8d98572 (diff)
Merge pull request #9833 from RandomShaper/fix-node-crash
Fix Node::move_child() crash if moving to the end plus one
-rwxr-xr-xscene/main/node.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 26d1deadf9..c3849f79df 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -311,6 +311,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--;
+
if (p_child->data.pos == p_pos)
return; //do nothing