[Bf-blender-cvs] [050276a1e6d] greasepencil-object: GPencil: Reset Brushes from old versions

Antonio Vazquez noreply at git.blender.org
Wed Nov 27 10:49:51 CET 2019


Commit: 050276a1e6d0cac008c3ad5fba41cad4f07bcbe2
Author: Antonio Vazquez
Date:   Wed Nov 27 10:49:39 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB050276a1e6d0cac008c3ad5fba41cad4f07bcbe2

GPencil: Reset Brushes from old versions

Sometimes old version brushes are damaged and must be removed when use Reset All

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

M	source/blender/editors/gpencil/gpencil_data.c

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

diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 41eb43da237..cfc224a445e 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1639,11 +1639,13 @@ static void gp_bruh_delete_mode_brushes(Main *bmain, const enum eContextObjectMo
   Brush *brush_next = NULL;
   for (Brush *brush = bmain->brushes.first; brush; brush = brush_next) {
     brush_next = brush->id.next;
-    if (brush->gpencil_settings == NULL) {
+
+    if ((brush->gpencil_settings == NULL) && (brush->ob_mode != OB_MODE_PAINT_GPENCIL)) {
       continue;
     }
 
-    short preset = brush->gpencil_settings->preset_type;
+    short preset = (brush->gpencil_settings) ? brush->gpencil_settings->preset_type :
+                                               GP_BRUSH_PRESET_UNKNOWN;
 
     if (preset != GP_BRUSH_PRESET_UNKNOWN) {
       /* Verify to delete only the brushes of the current mode. */
@@ -1665,7 +1667,7 @@ static void gp_bruh_delete_mode_brushes(Main *bmain, const enum eContextObjectMo
     }
 
     /* Before delete, unpinn any material of the brush. */
-    if (brush->gpencil_settings->material != NULL) {
+    if ((brush->gpencil_settings) && (brush->gpencil_settings->material != NULL)) {
       brush->gpencil_settings->material = NULL;
       brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
     }



More information about the Bf-blender-cvs mailing list