浏览代码

Fix Node::move_child() crash if moving to the end plus one

Fixes #9820.
Pedro J. Estébanez 8 年之前
父节点
当前提交
6c1b7fd899
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      scene/main/node.cpp

+ 5 - 0
scene/main/node.cpp

@@ -311,6 +311,11 @@ void Node::move_child(Node *p_child, int p_pos) {
 		ERR_FAIL_COND(data.blocked > 0);
 		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)
 	if (p_child->data.pos == p_pos)
 		return; //do nothing
 		return; //do nothing