[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54000] trunk/blender/source/blender/ editors/gpencil/gpencil_edit.c: Fix [#33962] Grease Pencil crashing blender

Bastien Montagne montagne29 at wanadoo.fr
Tue Jan 22 16:22:46 CET 2013


Revision: 54000
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54000
Author:   mont29
Date:     2013-01-22 15:22:46 +0000 (Tue, 22 Jan 2013)
Log Message:
-----------
Fix [#33962] Grease Pencil crashing blender

Own fault from grease pencil to curve enhacement. Fixed the bug itself, and made poll of convert operator more strict (no only active when there is something to convert, i.e. at least one stroke!).

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

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2013-01-22 14:55:34 UTC (rev 53999)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2013-01-22 15:22:46 UTC (rev 54000)
@@ -1387,12 +1387,15 @@
 static int gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOperator *op)
 {
 	Scene *scene = CTX_data_scene(C);
-	bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0);
-	bGPDstroke *gps = gpf->strokes.first;
+	bGPDframe *gpf = NULL;
+	bGPDstroke *gps = NULL;
 	bGPDspoint *pt;
 	double base_time, cur_time, prev_time = -1.0;
 	int i, valid = TRUE;
 	
+	if (!gpl || !(gpf = gpencil_layer_getframe(gpl, CFRA, 0)) || !(gps = gpf->strokes.first))
+		return FALSE;
+	
 	do {
 		base_time = cur_time = gps->inittime;
 		if (cur_time <= prev_time) {
@@ -1438,11 +1441,19 @@
 static int gp_convert_poll(bContext *C)
 {
 	bGPdata *gpd = gpencil_data_get_active(C);
+	bGPDlayer *gpl = NULL;
+	bGPDframe *gpf = NULL;
 	ScrArea *sa = CTX_wm_area(C);
 	Scene *scene = CTX_data_scene(C);
 
-	/* only if there's valid data, and the current view is 3D View */
-	return ((sa && sa->spacetype == SPACE_VIEW3D) && gpencil_layer_getactive(gpd) && (scene->obedit == NULL));
+	/* only if the current view is 3D View, if there's valid data (i.e. at least one stroke!),
+	 * and if we are not in edit mode!
+	 */
+	return ((sa && sa->spacetype == SPACE_VIEW3D) &&
+	        (gpl = gpencil_layer_getactive(gpd)) &&
+	        (gpf = gpencil_layer_getframe(gpl, CFRA, 0)) &&
+	        (gpf->strokes.first) &&
+	        (scene->obedit == NULL));
 }
 
 static int gp_convert_layer_exec(bContext *C, wmOperator *op)




More information about the Bf-blender-cvs mailing list