Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-03-17 05:53:56 +0300
committerJoshua Leung <aligorith@gmail.com>2011-03-17 05:53:56 +0300
commit63099d41b5aa6099dd813f113d8f6a9cb31c7cb6 (patch)
treea961f38746996e984a6b4b952af85d3bb14a0b57 /source/blender/editors/gpencil
parent3ac925b7d1da07020130529f2c35c6a01edadce7 (diff)
Bugfix: Grease Pencil paint didn't clean up properly after error-exits
This manisfested as an inability to draw any more strokes after trying to draw a stroke while the active layer was locked and then unlocking that layer to try and draw on it again.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c79
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)
{