소스 검색

Ensure primitive meshes are created before connected to changed signal.

Primitive meshes are special in that they aren't created until calling
one of their methods which cause it to actually create the mesh
resources.  If this is not done early enough, a changed signal can be
triggered from an unexpected thread resulting in a threading warning.

This follows the pattern of mesh_instance_3d which also does this before
connecting to the change signal.  Future cleanup could provide a better
means to populate the meshes.
Trevor Davenport 9 달 전
부모
커밋
70a55540b7
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      scene/2d/mesh_instance_2d.cpp

+ 3 - 0
scene/2d/mesh_instance_2d.cpp

@@ -65,6 +65,9 @@ void MeshInstance2D::set_mesh(const Ref<Mesh> &p_mesh) {
 	mesh = p_mesh;
 
 	if (mesh.is_valid()) {
+		// If mesh is a PrimitiveMesh, calling get_rid on it can trigger a changed callback
+		// so do this before connecting to the change signal.
+		mesh->get_rid();
 		mesh->connect_changed(callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw));
 	}