Fix #147756: Grease Pencil: Join Operator crash because of resolution attribute

When strokes from to different layers get joined together, if one layer
had the `resolution` attribute and the other did not. The new
`resolution` attribute would be left with uninitialized values and then
a crash would happen.

This fixes this by filling all attributes that didn't exist with their
default value.

This also ensures that when strokes are removed, the drawing is
tagged as dirty.

Pull Request: https://projects.blender.org/blender/blender/pulls/147948
This commit is contained in:
Casey Bianco-Davis
2025-10-17 17:21:33 +02:00
committed by Falk David
parent acb20247a5
commit 316fe67295
2 changed files with 20 additions and 0 deletions

View File

@@ -1135,11 +1135,30 @@ void copy_attributes_group_to_group(const AttributeAccessor src_attributes,
return;
}
const GVArraySpan src = *iter.get(src_domain);
const bool dst_already_exists = dst_attributes.contains(iter.name);
GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span(
iter.name, dst_domain, iter.data_type);
if (!dst) {
return;
}
if (!dst_already_exists) {
/* Skip filling with the default value if all of the data is going to be filled. */
if (!(dst_offsets.total_size() == dst.span.size() && selection.size() == dst_offsets.size()))
{
const CPPType &type = dst.span.type();
if (dst_attributes.is_builtin(iter.name)) {
if (const GPointer value = dst_attributes.get_builtin_default(iter.name)) {
type.fill_construct_n(value.get(), dst.span.data(), dst.span.size());
}
else {
type.fill_construct_n(type.default_value(), dst.span.data(), dst.span.size());
}
}
else {
type.fill_construct_n(type.default_value(), dst.span.data(), dst.span.size());
}
}
}
array_utils::copy_group_to_group(src_offsets, dst_offsets, selection, src, dst.span);
dst.finish();
});

View File

@@ -437,6 +437,7 @@ void remove_selected_points(Span<PointsRange> ranges_selected)
IndexMaskMemory memory;
const IndexMask combined_mask = IndexMask::from_union(item.value, memory);
dst_curves.remove_points(combined_mask, {});
item.key->tag_topology_changed();
}
}