[Bf-blender-cvs] [72e18c8] GPencil_EditStrokes: Add more sanity check error prints

Joshua Leung noreply at git.blender.org
Sun Sep 28 17:27:02 CEST 2014


Commit: 72e18c873e4be986366da4c09b7efb58a681a618
Author: Joshua Leung
Date:   Mon Sep 29 03:33:33 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rB72e18c873e4be986366da4c09b7efb58a681a618

Add more sanity check error prints

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 1275bb4..c10f7e4 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -346,11 +346,16 @@ static int gp_strokes_copy_poll(bContext *C)
 	return (gpl && gpl->actframe);
 }
 
-static int gp_strokes_copy_exec(bContext *C, wmOperator *UNUSED(op))
+static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
 {
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	bGPDlayer *gpl;
 	
+	if (gpd == NULL) {
+		BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
+		return OPERATOR_CANCELLED;
+	}
+	
 	/* for each visible (and editable) layer's selected strokes,
 	 * copy the strokes into a temporary buffer, then append
 	 * once all done
@@ -367,9 +372,12 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *UNUSED(op))
 			for (gps = gpf->strokes.first; gps; gps = gps->next) {
 				if (gps->flag & GP_STROKE_SELECT) {
 					/* make copy of stroke */
-					bGPDstroke *gpsd = MEM_dupallocN(gps);
+					bGPDstroke *gpsd;
+					
+					gpsd = MEM_dupallocN(gps);
 					gpsd->points = MEM_dupallocN(gps->points);
 					
+					gpsd->next = gpsd->prev = NULL;
 					BLI_addtail(&new_strokes, gpsd);
 					
 					/* deselect original stroke, or else the originals get moved too 
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 00811ef..8ccc572 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -93,6 +93,11 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	int action = RNA_enum_get(op->ptr, "action");
 	
+	if (gpd == NULL) {
+		BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
+		return OPERATOR_CANCELLED;
+	}
+	
 	/* for "toggle", test for existing selected strokes */
 	if (action == SEL_TOGGLE) {
 		action = SEL_SELECT;
@@ -241,13 +246,17 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
 	
 	bool changed = false;
 	
-	
-	/* for 3D View, init depth buffer stuff used for 3D projections... */
+	/* sanity checks */
+	if (gpd == NULL) {
+		BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
+		return OPERATOR_CANCELLED;
+	}
 	if (sa == NULL) {
 		BKE_report(op->reports, RPT_ERROR, "No active area");
 		return OPERATOR_CANCELLED;
 	}
 	
+	/* for 3D View, init depth buffer stuff used for 3D projections... */
 	if (sa->spacetype == SPACE_VIEW3D) {
 		wmWindow *win = CTX_wm_window(C);
 		View3D *v3d = (View3D *)CTX_wm_space_data(C);




More information about the Bf-blender-cvs mailing list