瀏覽代碼

Merge pull request #9834 from RandomShaper/fix-node-crash-2.1

Fix Node::move_child() crash if moving to the end plus one (2.1)
Rémi Verschelde 8 年之前
父節點
當前提交
ecc8382a8a
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      scene/main/node.cpp

+ 5 - 0
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);