[Bf-blender-cvs] [4762a9b09f9] master: GPencil: Fix unreported missing material panel for new Scene

Antonio Vazquez noreply at git.blender.org
Wed Sep 22 17:05:26 CEST 2021


Commit: 4762a9b09f98523093e5778e52b1ed8abf9fa331
Author: Antonio Vazquez
Date:   Wed Sep 22 17:05:04 2021 +0200
Branches: master
https://developer.blender.org/rB4762a9b09f98523093e5778e52b1ed8abf9fa331

GPencil: Fix unreported missing material panel for new Scene

When a new scene is created, the paint pointers are not available before using them, so the python panel exits because the pointer was None.

Now, the pointer is checked in order to display the materials panel as expected.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.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 f01e75dbab8..c31881fa194 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -525,7 +525,7 @@ class GreasePencilMaterialsPanel:
         is_view3d = (self.bl_space_type == 'VIEW_3D')
         tool_settings = context.scene.tool_settings
         gpencil_paint = tool_settings.gpencil_paint
-        brush = gpencil_paint.brush
+        brush = gpencil_paint.brush if gpencil_paint else None
 
         ob = context.object
         row = layout.row()
@@ -587,6 +587,9 @@ class GreasePencilMaterialsPanel:
                         ma = ob.material_slots[ob.active_material_index].material
                 else:
                     ma = gp_settings.material
+            else:
+                if len(ob.material_slots) > 0 and ob.active_material_index >= 0:
+                    ma = ob.material_slots[ob.active_material_index].material
 
             if ma is not None and ma.grease_pencil is not None:
                 gpcolor = ma.grease_pencil



More information about the Bf-blender-cvs mailing list