UI: Properly disable the Remove Material Slot Button in edit mode
Currently the remove material slot button still appears to be active while in edit mode. Attempting to use the button will result in an error "Unable to remove material slot in edit mode." Solution is to edit poll function to disable/gray out the remove material slot button while in edit mode similar to other buttons In the code a check was added for edit mode for the operator execution as a fix for bug #21822. However this check was never added to the polling function. This commit adds that check. Pull Request: https://projects.blender.org/blender/blender/pulls/139660
This commit is contained in:
committed by
Julian Eisel
parent
54c3c8f411
commit
bdbc2a9fd9
@@ -232,6 +232,23 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot)
|
||||
/** \name Material Slot Remove Operator
|
||||
* \{ */
|
||||
|
||||
static bool material_slot_remove_poll(bContext *C)
|
||||
{
|
||||
const Object *ob = blender::ed::object::context_object(C);
|
||||
|
||||
if (!object_materials_supported_poll_ex(C, ob)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Removing material slots in edit mode screws things up, see bug #21822. */
|
||||
if (BKE_object_is_in_editmode(ob)) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Unable to remove material slot in edit mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static wmOperatorStatus material_slot_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = blender::ed::object::context_object(C);
|
||||
@@ -240,12 +257,6 @@ static wmOperatorStatus material_slot_remove_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* Removing material slots in edit mode screws things up, see bug #21822. */
|
||||
if (BKE_object_is_in_editmode(ob)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
BKE_object_material_slot_remove(CTX_data_main(C), ob);
|
||||
|
||||
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
||||
@@ -271,7 +282,7 @@ void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
|
||||
|
||||
/* API callbacks. */
|
||||
ot->exec = material_slot_remove_exec;
|
||||
ot->poll = object_materials_supported_poll;
|
||||
ot->poll = material_slot_remove_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
||||
|
||||
Reference in New Issue
Block a user