Fix #132117: Grease Pencil: Material slots display logic fix

Sometimes context.material.grease_pencil will be none. E.g. when adding
a material slot in some grease pencil objects. This fix modified the
`poll` function to show material slots when the active object is a
grease pencil object or an active grease pencil material is present in
the context.

Pull Request: https://projects.blender.org/blender/blender/pulls/132158
This commit is contained in:
YimingWu
2024-12-20 11:46:34 +01:00
committed by YimingWu
parent eb8632e71f
commit 5c04893104

View File

@@ -92,8 +92,9 @@ class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, Panel):
@classmethod
def poll(cls, context):
ma = context.material
return ma and ma.grease_pencil
found_material = ma and ma.grease_pencil
found_object = context.object and context.object.type == 'GREASEPENCIL'
return found_material or found_object
# Used as parent for "Stroke" and "Fill" panels