Commit: 5f14bc1b47f3949cb5929153fcbb1916dc6cc0a8
Author: Antonioya
Date:   Mon Aug 29 22:17:57 2016 +0200
Branches: master
https://developer.blender.org/rB5f14bc1b47f3949cb5929153fcbb1916dc6cc0a8

GPencil: Fix segment fault when undo

When undo in UV/Image editor and press ESC key, there was segment fault
in Toolsettings because the reference was missing. Now the toolsetting
is loaded from context and not from local operator data.

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_paint.c 
b/source/blender/editors/gpencil/gpencil_paint.c
index 70a4b29..cc45cbd 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -2310,6 +2310,7 @@ static void gpencil_move_last_stroke_to_back(bContext *C)
 static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent 
*event)
 {
        tGPsdata *p = op->customdata;
+       ToolSettings *ts = CTX_data_tool_settings(C);
        int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass 
through to support MMB view nav, etc. */
        
        /* if (event->type == NDOF_MOTION)
@@ -2363,9 +2364,11 @@ static int gpencil_draw_modal(bContext *C, wmOperator 
*op, const wmEvent *event)
                /* exit() ends the current stroke before cleaning up */
                /* printf("\t\tGP - end of paint op + end of stroke\n"); */
                /* if drawing polygon and enable on back, must move stroke */
-               if ((p->scene->toolsettings->gpencil_flags & 
GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
-                       if (p->flags & GP_PAINTFLAG_STROKEADDED) {
-                               gpencil_move_last_stroke_to_back(C);
+               if (ts) {
+                       if ((ts->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) && 
(p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
+                               if (p->flags & GP_PAINTFLAG_STROKEADDED) {
+                                       gpencil_move_last_stroke_to_back(C);
+                               }
                        }
                }
                p->status = GP_STATUS_DONE;
@@ -2425,9 +2428,11 @@ static int gpencil_draw_modal(bContext *C, wmOperator 
*op, const wmEvent *event)
                        else {
                                /* printf("\t\tGP - end of stroke + op\n"); */
                                /* if drawing polygon and enable on back, must 
move stroke */
-                               if ((p->scene->toolsettings->gpencil_flags & 
GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
-                                       if (p->flags & 
GP_PAINTFLAG_STROKEADDED) {
-                                               
gpencil_move_last_stroke_to_back(C);
+                               if (ts) {
+                                       if ((ts->gpencil_flags & 
GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
+                                               if (p->flags & 
GP_PAINTFLAG_STROKEADDED) {
+                                                       
gpencil_move_last_stroke_to_back(C);
+                                               }
                                        }
                                }
                                p->status = GP_STATUS_DONE;
@@ -2511,9 +2516,11 @@ static int gpencil_draw_modal(bContext *C, wmOperator 
*op, const wmEvent *event)
                                 *       region (as above)
                                 */
                                /* if drawing polygon and enable on back, must 
move stroke */
-                               if ((p->scene->toolsettings->gpencil_flags & 
GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
-                                       if (p->flags & 
GP_PAINTFLAG_STROKEADDED) {
-                                               
gpencil_move_last_stroke_to_back(C);
+                               if (ts) {
+                                       if ((ts->gpencil_flags & 
GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
+                                               if (p->flags & 
GP_PAINTFLAG_STROKEADDED) {
+                                                       
gpencil_move_last_stroke_to_back(C);
+                                               }
                                        }
                                }
                                p->status = GP_STATUS_DONE;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to