From 63d77f028f6b37db95cc06077855ad2522123aaa Mon Sep 17 00:00:00 2001 From: YimingWu Date: Wed, 1 Oct 2025 15:17:47 +0200 Subject: [PATCH] Fix #147097: Prevent crash when joining meshes with different shape keys In 113d91aba8b3e4ddf4d8a1f791d3be1823fec80a the mesh joining operator is largely rewritten but the `join_positions_and_shape_keys` part didn't supply valid `bmain` and `id` for `BKE_key_add` which leads to crash. Now fixed by supplying correct arguments. Pull Request: https://projects.blender.org/blender/blender/pulls/147101 --- source/blender/editors/mesh/mesh_join.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/mesh/mesh_join.cc b/source/blender/editors/mesh/mesh_join.cc index 0e7b496a11d..6e9c2bec508 100644 --- a/source/blender/editors/mesh/mesh_join.cc +++ b/source/blender/editors/mesh/mesh_join.cc @@ -106,7 +106,8 @@ static VectorSet join_vertex_groups(const Span obje return vertex_group_names; } -static void join_positions_and_shape_keys(const Span objects_to_join, +static void join_positions_and_shape_keys(Main *bmain, + const Span objects_to_join, const OffsetIndices vert_ranges, const float4x4 &world_to_dst_mesh, Mesh &dst_mesh) @@ -122,7 +123,7 @@ static void join_positions_and_shape_keys(const Span objects_to_ const auto ensure_dst_key = [&]() { if (!dst_mesh.key) { - dst_mesh.key = BKE_key_add(nullptr, nullptr); + dst_mesh.key = BKE_key_add(bmain, &dst_mesh.id); dst_mesh.key->type = KEY_RELATIVE; } }; @@ -507,7 +508,8 @@ wmOperatorStatus join_objects_exec(bContext *C, wmOperator *op) float4x4 world_to_active_object; invert_m4_m4_safe_ortho(world_to_active_object.ptr(), active_object->object_to_world().ptr()); - join_positions_and_shape_keys(objects_to_join, vert_ranges, world_to_active_object, *dst_mesh); + join_positions_and_shape_keys( + bmain, objects_to_join, vert_ranges, world_to_active_object, *dst_mesh); MutableSpan dst_edges = dst_mesh->edges_for_write(); for (const int i : objects_to_join.index_range().drop_front(1)) {