Commit: 944812a1e8da3f51cdd3f5cb528dcb3b6373fc54
Author: Antonio Vazquez
Date:   Sun Mar 11 20:12:18 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB944812a1e8da3f51cdd3f5cb528dcb3b6373fc54

Fix problem when change mode if no brushes

When chnage mode, create the default brushes if they are missing.

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c 
b/source/blender/editors/gpencil/gpencil_edit.c
index d7450fb2ba1..9c76aa94b9c 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -58,6 +58,7 @@
 #include "BKE_main.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_brush.h"
 #include "BKE_gpencil.h"
 #include "BKE_paint.h"
 #include "BKE_library.h"
@@ -189,6 +190,8 @@ static int gpencil_paintmode_toggle_exec(bContext *C, 
wmOperator *op)
 
        WorkSpace *workspace = CTX_wm_workspace(C);
        bGPdata *gpd = ED_gpencil_data_get_active(C);
+       ToolSettings *ts = CTX_data_tool_settings(C);
+
        bool is_object = false;
        short mode;
        /* if using a gpencil object, use this datablock */
@@ -220,6 +223,17 @@ static int gpencil_paintmode_toggle_exec(bContext *C, 
wmOperator *op)
                workspace->object_mode = mode;
        }
 
+       /* be sure we have brushes */
+       if (ts->gp_paint == NULL) {
+               ts->gp_paint = MEM_callocN(sizeof(GpPaint), "GpPaint");
+       }
+
+       Paint *paint = &ts->gp_paint->paint;
+       /* if not exist, create a new one */
+       if (paint->brush == NULL) {
+               BKE_brush_gpencil_presets(C);
+       }
+
        /* setup other modes */
        ED_gpencil_setup_modes(C, gpd, mode);
        /* set cache as dirty */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to