Fix #120145: mesh_new_from_object crash with evaluated object type change

When the preserve_all_data_layers argument was passed, the object
would be reevaluated, assuming the type of the original object data.
However, the evaluated object type can change compared to the
original, so to reevaluate the original mesh we need to check that
the original object was also a mesh object.

Pull Request: https://projects.blender.org/blender/blender/pulls/126407
This commit is contained in:
Hans Goudey
2024-08-16 16:56:18 +02:00
committed by Hans Goudey
parent ff0c097fa1
commit 4b71496f56

View File

@@ -824,7 +824,12 @@ static Mesh *mesh_new_from_mesh_object(Depsgraph *depsgraph,
const bool preserve_all_data_layers,
const bool preserve_origindex)
{
if (preserve_all_data_layers || preserve_origindex) {
/* This function tries to reevaluate the object from the original data. If the original object
* was not a mesh object, this won't work because it uses mesh object evaluation which assumes
* the type of the original object data. */
if (!(object->runtime->data_orig && GS(object->runtime->data_orig->name) != ID_ME) &&
(preserve_all_data_layers || preserve_origindex))
{
return mesh_new_from_mesh_object_with_layers(depsgraph, object, preserve_origindex);
}
const Mesh *mesh_input = (const Mesh *)object->data;