[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25274] trunk/blender/source/blender/ makesrna/intern/rna_armature.c: raise an error when adding/ removing editbones when the armature is not in editmode ( without this blender crashes)

Campbell Barton ideasman42 at gmail.com
Thu Dec 10 09:54:17 CET 2009


Revision: 25274
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25274
Author:   campbellbarton
Date:     2009-12-10 09:54:16 +0100 (Thu, 10 Dec 2009)

Log Message:
-----------
raise an error when adding/removing editbones when the armature is not in editmode (without this blender crashes)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_armature.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_armature.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_armature.c	2009-12-10 06:51:52 UTC (rev 25273)
+++ trunk/blender/source/blender/makesrna/intern/rna_armature.c	2009-12-10 08:54:16 UTC (rev 25274)
@@ -94,13 +94,21 @@
 	}
 }
 
-EditBone *rna_Armature_edit_bone_new(bArmature *arm, char *name)
+EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, char *name)
 {
+	if(arm->edbo==NULL) {
+		BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant add an editbone.", arm->id.name+2);
+		return NULL;
+	}
 	return ED_armature_edit_bone_add(arm, name);
 }
 
-void rna_Armature_edit_bone_remove(bArmature *arm, EditBone *ebone)
+void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone *ebone)
 {
+	if(arm->edbo==NULL) {
+		BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant remove an editbone.", arm->id.name+2);
+		return;
+	}
 	ED_armature_edit_bone_remove(arm, ebone);
 }
 
@@ -701,15 +709,18 @@
 
 	/* add target */
 	func= RNA_def_function(srna, "new", "rna_Armature_edit_bone_new");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
 	RNA_def_function_ui_description(func, "Add a new bone.");
 	parm= RNA_def_string(func, "name", "Object", 0, "", "New name for the bone.");
 	RNA_def_property_flag(parm, PROP_REQUIRED);
+
 	/* return type */
 	parm= RNA_def_pointer(func, "bone", "EditBone", "", "Newly created edit bone.");
 	RNA_def_function_return(func, parm);
 
 	/* remove target */
 	func= RNA_def_function(srna, "remove", "rna_Armature_edit_bone_remove");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
 	RNA_def_function_ui_description(func, "Remove an existing bone from the armature.");
 	/* target to remove*/
 	parm= RNA_def_pointer(func, "bone", "EditBone", "", "EditBone to remove.");





More information about the Bf-blender-cvs mailing list