[Bf-blender-cvs] [3ce3163] master: Fixes for GPencil Copy and Paste

Joshua Leung noreply at git.blender.org
Mon May 9 09:43:43 CEST 2016


Commit: 3ce31633796cd1139cff96eaa4697d6d6f8ba10e
Author: Joshua Leung
Date:   Mon May 9 19:41:48 2016 +1200
Branches: master
https://developer.blender.org/rB3ce31633796cd1139cff96eaa4697d6d6f8ba10e

Fixes for GPencil Copy and Paste

* Fix "Attempt to free NULL pointer" when copying strokes for the first time

* Fix poll callback on "paste" operator, so that it is possible to paste
  strokes when there are no editable strokes visible.

===================================================================

M	source/blender/editors/gpencil/gpencil_edit.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 8e0a83d..bd1697b 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -296,12 +296,13 @@ void ED_gpencil_strokes_copybuf_free(void)
 	for (gps = gp_strokes_copypastebuf.first; gps; gps = gpsn) {
 		gpsn = gps->next;
 		
-		MEM_freeN(gps->points);
-		MEM_freeN(gps->triangles);
+		if (gps->points)    MEM_freeN(gps->points);
+		if (gps->triangles) MEM_freeN(gps->triangles);
+		
 		BLI_freelinkN(&gp_strokes_copypastebuf, gps);
 	}
 	
-	BLI_listbase_clear(&gp_strokes_copypastebuf);
+	gp_strokes_copypastebuf.first = gp_strokes_copypastebuf.last = NULL;
 }
 
 /* --------------------- */
@@ -386,6 +387,14 @@ void GPENCIL_OT_copy(wmOperatorType *ot)
 /* --------------------- */
 /* Paste selected strokes */
 
+static int gp_strokes_paste_poll(bContext *C)
+{
+	/* 1) Must have GP layer to paste to...
+	 * 2) Copy buffer must at least have something (though it may be the wrong sort...)
+	 */
+	return (CTX_data_active_gpencil_layer(C) != NULL) && (!BLI_listbase_is_empty(&gp_strokes_copypastebuf));
+}
+
 static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene = CTX_data_scene(C);
@@ -490,7 +499,7 @@ void GPENCIL_OT_paste(wmOperatorType *ot)
 	
 	/* callbacks */
 	ot->exec = gp_strokes_paste_exec;
-	ot->poll = gp_stroke_edit_poll;
+	ot->poll = gp_strokes_paste_poll;
 	
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;




More information about the Bf-blender-cvs mailing list