diff options
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 472750113b9..e7d52ddf301 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1246,7 +1246,46 @@ static void gp_paint_cleanup (tGPsdata *p) gp_paint_strokeend(p); /* "unlock" frame */ - p->gpf->flag &= ~GP_FRAME_PAINT; + if (p->gpf) + p->gpf->flag &= ~GP_FRAME_PAINT; +} + +/* ------------------------------- */ + +static void gpencil_draw_exit (bContext *C, wmOperator *op) +{ + tGPsdata *p= op->customdata; + + /* clear edit flags */ + G.f &= ~G_GREASEPENCIL; + + /* restore cursor to indicate end of drawing */ + WM_cursor_restore(CTX_wm_window(C)); + + /* don't assume that operator data exists at all */ + if (p) { + /* check size of buffer before cleanup, to determine if anything happened here */ + if (p->paintmode == GP_PAINTMODE_ERASER) { + // TODO clear radial cursor thing + // XXX draw_sel_circle(NULL, p.mvalo, 0, p.radius, 0); + } + + /* cleanup */ + gp_paint_cleanup(p); + gp_session_cleanup(p); + + /* finally, free the temp data */ + MEM_freeN(p); + } + + op->customdata= NULL; +} + +static int gpencil_draw_cancel (bContext *C, wmOperator *op) +{ + /* this is just a wrapper around exit() */ + gpencil_draw_exit(C, op); + return OPERATOR_CANCELLED; } /* ------------------------------- */ @@ -1261,14 +1300,14 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) p= op->customdata= gp_session_initpaint(C); if ((p == NULL) || (p->status == GP_STATUS_ERROR)) { /* something wasn't set correctly in context */ - gp_session_cleanup(p); + gpencil_draw_exit(C, op); return 0; } /* init painting data */ gp_paint_initstroke(p, paintmode); if (p->status == GP_STATUS_ERROR) { - gp_session_cleanup(p); + gpencil_draw_exit(C, op); return 0; } @@ -1281,40 +1320,6 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) /* ------------------------------- */ -static void gpencil_draw_exit (bContext *C, wmOperator *op) -{ - tGPsdata *p= op->customdata; - - /* clear edit flags */ - G.f &= ~G_GREASEPENCIL; - - /* restore cursor to indicate end of drawing */ - WM_cursor_restore(CTX_wm_window(C)); - - /* check size of buffer before cleanup, to determine if anything happened here */ - if (p->paintmode == GP_PAINTMODE_ERASER) { - // TODO clear radial cursor thing - // XXX draw_sel_circle(NULL, p.mvalo, 0, p.radius, 0); - } - - /* cleanup */ - gp_paint_cleanup(p); - gp_session_cleanup(p); - - /* finally, free the temp data */ - MEM_freeN(p); - op->customdata= NULL; -} - -static int gpencil_draw_cancel (bContext *C, wmOperator *op) -{ - /* this is just a wrapper around exit() */ - gpencil_draw_exit(C, op); - return OPERATOR_CANCELLED; -} - -/* ------------------------------- */ - /* update UI indicators of status, including cursor and header prints */ static void gpencil_draw_status_indicators (tGPsdata *p) { |