Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-12-10 11:54:16 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-10 11:54:16 +0300
commit900165bc722ebcec55a61916ff6aad601da1edd0 (patch)
treeaa848c7e5bfd004003273dbdbd3dba2208138d1e
parent4bcb759c946e2a3f2f676d2f57e3536478dc7613 (diff)
raise an error when adding/removing editbones when the armature is not in editmode (without this blender crashes)
-rw-r--r--source/blender/makesrna/intern/rna_armature.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 4859f23967f..cb030bf0c31 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -94,13 +94,21 @@ static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value)
}
}
-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 @@ static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop)
/* 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.");