Fix #142290: crash pasting linked ID in its source library

The core issue here seems to be that the pasted object is turned into an Empty
but it still has all the modifiers. Later when the object is copied by the
depsgraph, the modifiers are not copied along, confusing some code.

Right now, this patch is rather defensive, so it solves the specific crash and
maybe similar cases that could come up in the future. One could separately also
clear all modifiers when turning the object into an Empty.

Pull Request: https://projects.blender.org/blender/blender/pulls/143029
This commit is contained in:
Jacques Lucke
2025-07-24 10:22:47 +02:00
parent df625835c4
commit 6ca5c0fa92

View File

@@ -953,6 +953,12 @@ void DepsgraphNodeBuilder::build_object_modifiers(Object *object)
Object *ob_eval = reinterpret_cast<Object *>(id_node->id_cow);
ModifierData *md_eval = reinterpret_cast<ModifierData *>(
BLI_findlink(&ob_eval->modifiers, modifier_index));
if (!md_eval) {
/* The modifiers may not be available on the evaluated object if the object has an
* error that turned it into an Empty. Modifiers are not copied on this object type.
* Also see #142290. */
return;
}
/* Set flag that the modifier can check when it is evaluated. */
const bool is_user_modified = modifier_node->flag & DEPSOP_FLAG_USER_MODIFIED;
SET_FLAG_FROM_TEST(md_eval->flag, is_user_modified, eModifierFlag_UserModified);