[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35584] trunk/blender/source/blender/ editors/gpencil/gpencil_paint.c: Bugfix: Grease Pencil paint didn' t clean up properly after error-exits

Joshua Leung aligorith at gmail.com
Thu Mar 17 03:53:56 CET 2011


Revision: 35584
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35584
Author:   aligorith
Date:     2011-03-17 02:53:56 +0000 (Thu, 17 Mar 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/gpencil/gpencil_paint.c

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2011-03-16 22:25:31 UTC (rev 35583)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2011-03-17 02:53:56 UTC (rev 35584)
@@ -1246,12 +1246,51 @@
 	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;
+}
+
+/* ------------------------------- */
+
+
 static int gpencil_draw_init (bContext *C, wmOperator *op)
 {
 	tGPsdata *p;
@@ -1261,14 +1300,14 @@
 	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 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)
 {




More information about the Bf-blender-cvs mailing list