[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46589] trunk/blender/source/blender/ editors/gpencil/gpencil_paint.c: previous commit didnt work right, the flag is still needed, wrap access with functions so the NULL check is always done.

Campbell Barton ideasman42 at gmail.com
Sat May 12 23:38:35 CEST 2012


Revision: 46589
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46589
Author:   campbellbarton
Date:     2012-05-12 21:38:35 +0000 (Sat, 12 May 2012)
Log Message:
-----------
previous commit didnt work right, the flag is still needed, wrap access with functions so the NULL check is always done.

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	2012-05-12 21:37:01 UTC (rev 46588)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2012-05-12 21:38:35 UTC (rev 46589)
@@ -128,7 +128,8 @@
 
 /* Runtime flags */
 enum {
-	GP_PAINTFLAG_FIRSTRUN       = (1 << 0)    /* operator just started */
+	GP_PAINTFLAG_FIRSTRUN       = (1 << 0),    /* operator just started */
+	GP_PAINTFLAG_STROKEADDED    = (1 << 1)
 };
 
 /* ------ */
@@ -142,11 +143,17 @@
 /* minimum length of new segment before new point can be added */
 #define MIN_EUCLIDEAN_PX    (U.gp_euclideandist)
 
-static int gp_stroke_is_added(tGPsdata *p)
+static int gp_stroke_added_check(tGPsdata *p)
 {
-	return (p->gpf && p->gpf->strokes.last);
+	return (p->gpf && p->gpf->strokes.last && p->flags & GP_PAINTFLAG_STROKEADDED);
 }
 
+static void gp_stroke_added_enable(tGPsdata *p)
+{
+	BLI_assert(p->gpf->strokes.last != NULL);
+	p->flags |= GP_PAINTFLAG_STROKEADDED;
+}
+
 /* ------ */
 /* Forward defines for some functions... */
 
@@ -394,7 +401,7 @@
 		 * to stroke. This allows to draw lines more interactively (see new segment
 		 * during mouse slide, i.e.) 
 		 */
-		if (gp_stroke_is_added(p)) {
+		if (gp_stroke_added_check(p)) {
 			bGPDstroke *gps = p->gpf->strokes.last;
 			bGPDspoint *pts;
 
@@ -582,7 +589,7 @@
 	 * coordinates are getting added to stroke immediately to allow more
 	 * interactive behavior */
 	if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
-		if (gp_stroke_is_added(p)) {
+		if (gp_stroke_added_check(p)) {
 			return;
 		}
 	}
@@ -718,6 +725,7 @@
 
 	/* add stroke to frame */
 	BLI_addtail(&p->gpf->strokes, gps);
+	gp_stroke_added_enable(p);
 }
 
 /* --- 'Eraser' for 'Paint' Tool ------ */
@@ -1803,7 +1811,7 @@
 	//printf("\tGP - handle modal event...\n");
 	
 	/* exit painting mode (and/or end current stroke) */
-	if (ELEM4(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY)) {
+	if (ELEM5(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, RIGHTMOUSE)) {
 		/* exit() ends the current stroke before cleaning up */
 		//printf("\t\tGP - end of paint op + end of stroke\n");
 		p->status = GP_STATUS_DONE;
@@ -1811,7 +1819,7 @@
 	}
 	
 	/* toggle painting mode upon mouse-button movement */
-	if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE)) {
+	if (event->type == LEFTMOUSE) {
 		/* if painting, end stroke */
 		if (p->status == GP_STATUS_PAINTING) {
 			int sketch = 0;




More information about the Bf-blender-cvs mailing list