Fix T84593: Operators on material (linked to local object but with

linked obdata) fail

Caused by rB1a650fdcb286.

Above commit made polling more restricitive in that it did not allow for
actions on material slots (linked to object, not object data) on objects
with liked object data. This should be allowed though.

Maniphest Tasks: T84593

https://developer.blender.org/D10078
This commit is contained in:
Philipp Oeser 2021-01-11 17:32:10 +01:00
parent 55059af01d
commit ff51afb194
Notes: blender-bot 2023-02-14 06:55:40 +01:00
Referenced by issue #84593, Cannot create new material on linked mesh, even though material_slot input is set to object instead of data.
1 changed files with 11 additions and 3 deletions

View File

@ -148,10 +148,18 @@ static bool object_materials_supported_poll_ex(bContext *C, const Object *ob)
if (!ED_operator_object_active_local_editable_ex(C, ob)) {
return false;
}
if (!OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
return false;
}
/* Material linked to object. */
if (ob->matbits && ob->actcol && ob->matbits[ob->actcol - 1]) {
return true;
}
/* Material linked to obdata. */
const ID *data = ob->data;
return (OB_TYPE_SUPPORT_MATERIAL(ob->type) &&
/* Object data checks. */
data && !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data));
return (data && !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data));
}
static bool object_materials_supported_poll(bContext *C)