diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-24 10:40:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-24 10:40:28 +0400 |
commit | adae794233e168aa4046b560c43db6b48725cc08 (patch) | |
tree | 07760de7ef9a04b9912250d77b6450f05ac1be4c | |
parent | 70e99a3476aa66fa3ef1238643e9cf37e41ce0cd (diff) |
py/rna remove functions now all work in a similar way.
- some remove() functions took an int argument rather then the item to remove.
- disallow None argument.
- raise an error if the item isnt in the collection.
-rw-r--r-- | source/blender/blenkernel/BKE_constraint.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_fcurve.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fmodifier.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_animation.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_armature.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_color.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 35 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 45 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 25 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 2 |
17 files changed, 94 insertions, 99 deletions
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 64e9636cae7..d6e0075df1e 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -136,7 +136,6 @@ struct bConstraint *add_ob_constraint(struct Object *ob, const char *name, short struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type); int remove_constraint(ListBase *list, struct bConstraint *con); -int remove_constraint_index(ListBase *list, int index); void remove_constraints_type(ListBase *list, short type, short last_only); /* Constraints + Proxies function prototypes */ diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index 6de0c55af3b..95e0cfc3a91 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -161,7 +161,6 @@ struct FModifier *add_fmodifier(ListBase *modifiers, int type); struct FModifier *copy_fmodifier(struct FModifier *src); void copy_fmodifiers(ListBase *dst, ListBase *src); int remove_fmodifier(ListBase *modifiers, struct FModifier *fcm); -int remove_fmodifier_index(ListBase *modifiers, int index); void free_fmodifiers(ListBase *modifiers); struct FModifier *find_active_fmodifier(ListBase *modifiers); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b415484c1c1..57e5630da19 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3987,17 +3987,6 @@ int remove_constraint (ListBase *list, bConstraint *con) return 0; } -/* Remove the nth constraint from the given constraint stack */ -int remove_constraint_index (ListBase *list, int index) -{ - bConstraint *con= BLI_findlink(list, index); - - if (con) - return remove_constraint(list, con); - else - return 0; -} - /* Remove all the constraints of the specified type from the given constraint stack */ void remove_constraints_type (ListBase *list, short type, short last_only) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 124e6365777..f63b58fe489 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1087,13 +1087,6 @@ int remove_fmodifier (ListBase *modifiers, FModifier *fcm) } } -/* Remove and free the nth F-Modifier from the given stack */ -int remove_fmodifier_index (ListBase *modifiers, int index) -{ - FModifier *fcm= BLI_findlink(modifiers, index); - return remove_fmodifier(modifiers, fcm); -} - /* Remove all of a given F-Curve's modifiers */ void free_fmodifiers (ListBase *modifiers) { diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 53f6252a714..42cd6fd5911 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -570,7 +570,7 @@ static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); /* path to remove */ parm= RNA_def_pointer(func, "path", "KeyingSetPath", "Path", ""); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); /* Remove All Paths */ diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 8b21fd2c80a..f2abe690218 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -108,6 +108,12 @@ void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant remove an editbone.", arm->id.name+2); return; } + + if(BLI_findindex(arm->edbo, ebone) == -1) { + BKE_reportf(reports, RPT_ERROR, "Armature '%s' doesn't contain bone '%s'.", arm->id.name+2, ebone->name); + return; + } + ED_armature_edit_bone_remove(arm, ebone); } @@ -712,7 +718,7 @@ static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop) 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"); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } static void rna_def_armature(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index ba3f2b09a20..89f3e459105 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -465,9 +465,8 @@ static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "remove", "rna_ColorRampElement_remove"); RNA_def_function_ui_description(func, "Delete element from ColorRamp"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - //parm= RNA_def_int(func, "index", 0, 0, 31, "Index", "Element to delete.", 0, 31); parm= RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } static void rna_def_color_ramp(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 4995a50fff6..f5eace91831 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -985,7 +985,7 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); */ } @@ -1012,7 +1012,7 @@ static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); */ } @@ -1041,7 +1041,7 @@ static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index b37e5f91538..a55c3f10095 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -385,9 +385,13 @@ DriverVar *rna_Driver_new_variable(ChannelDriver *driver) return driver_add_new_variable(driver); } -void rna_Driver_remove_variable(ChannelDriver *driver, DriverVar *dvar) +void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar) { - /* call the API function for this */ + if(BLI_findindex(&driver->variables, dvar) == -1) { + BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver."); + return; + } + driver_free_variable(driver, dvar); } @@ -410,9 +414,13 @@ static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type) return add_fmodifier(&fcu->modifiers, type); } -static int rna_FCurve_modifiers_remove(FCurve *fcu, int index) +static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, FModifier *fcm) { - return remove_fmodifier_index(&fcu->modifiers, index); + if(BLI_findindex(&fcu->modifiers, fcm) == -1) { + BKE_reportf(reports, RPT_ERROR, "FCurveModifier '%s' not found in fcurve.", fcm->name); + return; + } + remove_fmodifier(&fcu->modifiers, fcm); } static void rna_FModifier_active_set(PointerRNA *ptr, int value) @@ -1094,10 +1102,11 @@ static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop /* remove variable */ func= RNA_def_function(srna, "remove", "rna_Driver_remove_variable"); - RNA_def_function_ui_description(func, "Remove an existing variable from the driver."); - /* target to remove */ - parm= RNA_def_pointer(func, "var", "DriverVariable", "", "Variable to remove from the driver."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_function_ui_description(func, "Remove an existing variable from the driver."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + /* target to remove */ + parm= RNA_def_pointer(func, "variable", "DriverVariable", "", "Variable to remove from the driver."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } static void rna_def_channeldriver(BlenderRNA *brna) @@ -1282,13 +1291,11 @@ static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(parm, PROP_REQUIRED); func= RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a modifier from this fcurve."); - /* return type */ - parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully."); - RNA_def_function_return(func, parm); - /* object to add */ - parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); - RNA_def_property_flag(parm, PROP_REQUIRED); + /* modifier to remove */ + parm= RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } /* fcurve.keyframe_points */ diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 49359e03985..4d77bfb9351 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -517,7 +517,7 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a camera from the current blendfile."); parm= RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) @@ -540,10 +540,9 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "remove", "rna_Main_scenes_remove"); RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); - parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_ui_description(func, "Remove a scene from the current blendfile."); - RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) @@ -569,10 +568,10 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_objects_remove"); + RNA_def_function_ui_description(func, "Remove a object from the current blendfile."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); - RNA_def_function_ui_description(func, "Remove a object from the current blendfile."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) @@ -597,7 +596,7 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a material from the current blendfile."); parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) { @@ -628,7 +627,7 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a node tree from the current blendfile."); parm= RNA_def_pointer(func, "tree", "NodeTree", "", "Node tree to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); #endif } void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) @@ -653,7 +652,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile."); parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) { @@ -677,7 +676,7 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile."); parm= RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) { @@ -726,7 +725,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove an image from the current blendfile."); parm= RNA_def_pointer(func, "image", "Image", "", "Image to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) @@ -751,7 +750,7 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a lattice from the current blendfile."); parm= RNA_def_pointer(func, "lattice", "Lattice", "", "Lattice to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) { @@ -777,7 +776,7 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a curve from the current blendfile."); parm= RNA_def_pointer(func, "curve", "Curve", "", "Curve to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) { @@ -801,7 +800,7 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a metaball from the current blendfile."); parm= RNA_def_pointer(func, "metaball", "MetaBall", "", "MetaBall to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) { @@ -826,7 +825,7 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a font from the current blendfile."); parm= RNA_def_pointer(func, "vfont", "VectorFont", "", "Font to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) { @@ -850,7 +849,7 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a texture from the current blendfile."); parm= RNA_def_pointer(func, "texture", "Texture", "", "Texture to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) { @@ -874,7 +873,7 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a brush from the current blendfile."); parm= RNA_def_pointer(func, "brush", "Brush", "", "Brush to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) @@ -899,7 +898,7 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a world from the current blendfile."); parm= RNA_def_pointer(func, "world", "World", "", "World to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) @@ -924,7 +923,7 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a group from the current blendfile."); parm= RNA_def_pointer(func, "group", "Group", "", "Group to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) { @@ -948,7 +947,7 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a text from the current blendfile."); parm= RNA_def_pointer(func, "text", "Text", "", "Text to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); /* load func */ func= RNA_def_function(srna, "load", "rna_Main_texts_load"); @@ -986,7 +985,7 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a armature from the current blendfile."); parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) { @@ -1010,7 +1009,7 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a action from the current blendfile."); parm= RNA_def_pointer(func, "action", "Action", "", "Action to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) { @@ -1034,7 +1033,7 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a particle settings instance from the current blendfile."); parm= RNA_def_pointer(func, "particle", "ParticleSettings", "", "Particle Settings to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) { diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 5576df2e068..94d5c8c4cb0 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1682,7 +1682,7 @@ static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); */ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "MeshColorLayer"); @@ -1723,7 +1723,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); */ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 59fff17b1ea..e364b075024 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -240,7 +240,7 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "lastelem"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 7cfff23b1c6..f4449f4ebd0 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1014,21 +1014,22 @@ static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value) constraints_set_active(&ob->constraints, (bConstraint *)value.data); } -static bConstraint *rna_Object_constraint_new(Object *object, int type) +static bConstraint *rna_Object_constraints_new(Object *object, int type) { WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object); return add_ob_constraint(object, NULL, type); } -static int rna_Object_constraint_remove(Object *object, int index) +static void rna_Object_constraints_remove(Object *object, ReportList *reports, bConstraint *con) { - int ok = remove_constraint_index(&object->constraints, index); - if(ok) { - ED_object_constraint_set_active(object, NULL); - WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT, object); + if(BLI_findindex(&object->constraints, con) == -1) { + BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'.", con->name, object->id.name+2); + return; } - return ok; + remove_constraint(&object->constraints, con); + ED_object_constraint_set_active(object, NULL); + WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT, object); } static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, char *name, int type) @@ -1380,23 +1381,21 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) /* Constraint collection */ - func= RNA_def_function(srna, "new", "rna_Object_constraint_new"); + func= RNA_def_function(srna, "new", "rna_Object_constraints_new"); RNA_def_function_ui_description(func, "Add a new constraint to this object"); - /* return type */ - parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint."); - RNA_def_function_return(func, parm); /* object to add */ parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add."); RNA_def_property_flag(parm, PROP_REQUIRED); - - func= RNA_def_function(srna, "remove", "rna_Object_constraint_remove"); - RNA_def_function_ui_description(func, "Remove a constraint from this object."); /* return type */ - parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully."); + parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint."); RNA_def_function_return(func, parm); - /* object to add */ - parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); - RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "remove", "rna_Object_constraints_remove"); + RNA_def_function_ui_description(func, "Remove a constraint from this object."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + /* constraint to remove */ + parm= RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } /* object.modifiers */ @@ -1444,7 +1443,7 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove an existing modifier from the object."); /* target to remove*/ parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } /* object.particle_systems */ diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 73c27d70b00..e4a3be023ca 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -62,6 +62,8 @@ #include "MEM_guardedalloc.h" +#include "WM_api.h" + #include "RNA_access.h" static void rna_Pose_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -442,12 +444,17 @@ static bConstraint *rna_PoseChannel_constraints_new(bPoseChannel *pchan, int typ return add_pose_constraint(NULL, pchan, NULL, type); } -static int rna_PoseChannel_constraints_remove(bPoseChannel *pchan, int index) +static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, bConstraint *con) { + if(BLI_findindex(&pchan->constraints, con) == -1) { + BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in pose bone '%s'.", con->name, pchan->name); + return; + } + // TODO - //ED_object_constraint_set_active(object, NULL); - //WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT, object); - return remove_constraint_index(&pchan->constraints, index); + //ED_object_constraint_set_active(id, NULL); + WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT, id); + remove_constraint(&pchan->constraints, con); } static int rna_PoseChannel_proxy_editable(PointerRNA *ptr) @@ -652,12 +659,10 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro func= RNA_def_function(srna, "remove", "rna_PoseChannel_constraints_remove"); RNA_def_function_ui_description(func, "Remove a constraint from this object."); - /* return type */ - parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully."); - RNA_def_function_return(func, parm); - /* object to add */ - parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID); /* ID needed for refresh */ + /* constraint to remove */ + parm= RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } static void rna_def_pose_channel(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 715613cbd80..157795f7c20 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2950,7 +2950,7 @@ static void rna_def_scene_keying_sets(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); */ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index fb1b48b9344..0c3a22e4c16 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2787,7 +2787,7 @@ void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_NO_SELF); RNA_def_function_ui_description(func, "Remove addon."); parm= RNA_def_pointer(func, "addon", "Addon", "", "Addon to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } void RNA_def_userdef(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index edd932f4ca7..41de875aa8c 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1262,7 +1262,7 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve."); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); */ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "KeyConfig"); |