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.
This commit is contained in:
Joshua Leung
2011-03-17 02:53:56 +00:00
parent 3ac925b7d1
commit 63099d41b5

View File

@@ -1246,37 +1246,8 @@ static void gp_paint_cleanup (tGPsdata *p)
gp_paint_strokeend(p);
/* "unlock" frame */
p->gpf->flag &= ~GP_FRAME_PAINT;
}
/* ------------------------------- */
static int gpencil_draw_init (bContext *C, wmOperator *op)
{
tGPsdata *p;
int paintmode= RNA_enum_get(op->ptr, "mode");
/* check context */
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);
return 0;
}
/* init painting data */
gp_paint_initstroke(p, paintmode);
if (p->status == GP_STATUS_ERROR) {
gp_session_cleanup(p);
return 0;
}
/* radius for eraser circle is defined in userprefs now */
p->radius= U.gp_eraser;
/* everything is now setup ok */
return 1;
if (p->gpf)
p->gpf->flag &= ~GP_FRAME_PAINT;
}
/* ------------------------------- */
@@ -1291,18 +1262,22 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op)
/* 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);
/* 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);
}
/* cleanup */
gp_paint_cleanup(p);
gp_session_cleanup(p);
/* finally, free the temp data */
MEM_freeN(p);
op->customdata= NULL;
}
@@ -1315,6 +1290,36 @@ static int gpencil_draw_cancel (bContext *C, wmOperator *op)
/* ------------------------------- */
static int gpencil_draw_init (bContext *C, wmOperator *op)
{
tGPsdata *p;
int paintmode= RNA_enum_get(op->ptr, "mode");
/* check context */
p= op->customdata= gp_session_initpaint(C);
if ((p == NULL) || (p->status == GP_STATUS_ERROR)) {
/* something wasn't set correctly in context */
gpencil_draw_exit(C, op);
return 0;
}
/* init painting data */
gp_paint_initstroke(p, paintmode);
if (p->status == GP_STATUS_ERROR) {
gpencil_draw_exit(C, op);
return 0;
}
/* radius for eraser circle is defined in userprefs now */
p->radius= U.gp_eraser;
/* everything is now setup ok */
return 1;
}
/* ------------------------------- */
/* update UI indicators of status, including cursor and header prints */
static void gpencil_draw_status_indicators (tGPsdata *p)
{