[Bf-blender-cvs] [a518ec27fc7] greasepencil-object: GPencil: Handle 0 materials in material change

Antonio Vazquez noreply at git.blender.org
Thu Apr 16 09:32:34 CEST 2020


Commit: a518ec27fc76875e0cfc944c3e4beeed839b9b43
Author: Antonio Vazquez
Date:   Thu Apr 16 09:29:34 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rBa518ec27fc76875e0cfc944c3e4beeed839b9b43

GPencil: Handle 0 materials in material change

===================================================================

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_view3d.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 7a2dea10635..6b9e41db12a 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -366,10 +366,16 @@ class GPENCIL_MT_material_active(Menu):
 
     @classmethod
     def poll(cls, context):
+        ob = context.active_object
         tool_settings = context.scene.tool_settings
         mode = tool_settings.gpencil_paint.color_mode
+        if mode != 'MATERIAL':
+            return False
+
+        if ob is None or len(ob.material_slots) == 0:
+            return False
 
-        return  (mode == 'MATERIAL')
+        return True
 
     def draw(self, context):
         layout = self.layout
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index d368cb394b1..cc0d52f4f2e 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -7057,7 +7057,7 @@ def draw_gpencil_layer_active(context, layout):
 
 def draw_gpencil_material_active(context, layout):
         ob = context.active_object
-        if ob.active_material_index >= 0:
+        if ob and len(ob.material_slots) > 0 and ob.active_material_index >= 0:
             ma = ob.material_slots[ob.active_material_index].material
             if ma:
                 layout.label(text="Active Material")



More information about the Bf-blender-cvs mailing list