Fix crash calling "Set Active Modifier" without an active object

This commit is contained in:
Campbell Barton
2025-03-06 15:47:16 +11:00
parent 1635595f94
commit fa6975b440
3 changed files with 9 additions and 0 deletions

View File

@@ -583,6 +583,8 @@ bool ED_operator_nla_active(bContext *C);
bool ED_operator_info_active(bContext *C);
bool ED_operator_console_active(bContext *C);
/** Only check there is an active object (no visibility check). */
bool ED_operator_object_active_only(bContext *C);
bool ED_operator_object_active(bContext *C);
bool ED_operator_object_active_editable_ex(bContext *C, const Object *ob);
bool ED_operator_object_active_editable(bContext *C);

View File

@@ -2606,6 +2606,7 @@ void OBJECT_OT_modifier_set_active(wmOperatorType *ot)
ot->invoke = modifier_set_active_invoke;
ot->exec = modifier_set_active_exec;
ot->poll = ED_operator_object_active_only;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);

View File

@@ -408,6 +408,12 @@ static bool ed_object_hidden(const Object *ob)
return ((ob->visibility_flag & OB_HIDE_VIEWPORT) && !(ob->mode & OB_MODE_EDIT));
}
bool ED_operator_object_active_only(bContext *C)
{
Object *ob = blender::ed::object::context_active_object(C);
return (ob != nullptr);
}
bool ED_operator_object_active(bContext *C)
{
Object *ob = blender::ed::object::context_active_object(C);