Fix T100394: Regression: Duplicating a modifier causes a crash

Need to update relations when modifiers are added or removed
since those create nodes in the dependency graph.

Added an assert statement to point at possible culprit so
that issues can be fixed more quickly.
This commit is contained in:
Sergey Sharybin 2022-08-15 11:54:21 +02:00
parent 3c9956fe55
commit d8841d0aa3
Notes: blender-bot 2023-02-14 09:09:43 +01:00
Referenced by issue #100394, Regression: Duplicating a modifier causes a crash
2 changed files with 8 additions and 0 deletions

View File

@ -69,6 +69,10 @@ void deg_evaluate_object_modifiers_mode_node_visibility(::Depsgraph *depsgraph,
OperationNode *modifier_node = geometry_component->find_operation(OperationCode::MODIFIER,
modifier->name);
BLI_assert_msg(modifier_node != nullptr,
"Modifier node in depsgraph is not found. Likely due to missing "
"DEG_relations_tag_update().");
const bool modifier_enabled = modifier->mode & modifier_mode;
const int mute_flag = modifier_enabled ? 0 : DEPSOP_FLAG_MUTE;
if ((modifier_node->flag & DEPSOP_FLAG_MUTE) != mute_flag) {

View File

@ -486,6 +486,9 @@ bool ED_object_modifier_move_to_index(ReportList *reports,
}
}
/* NOTE: Dependency graph only uses modifier nodes for visibility updates, and exact order of
* modifier nodes in the graph does not matter. */
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
@ -1668,6 +1671,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;