mirror of
https://github.com/godotengine/godot.git
synced 2025-04-01 00:41:35 +08:00
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.
This commit is contained in:
parent
bbc54692c0
commit
70a55540b7
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user