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>2012-11-02 13:41:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-02 13:41:26 +0400
commita31449edaddc1be80676c77babf079a9f137c42d (patch)
tree30bf1759a51f5def43dc000d6af7112642404770 /source/blender/makesrna/intern/rna_pose.c
parent2944d42c262d9d4459e356dc8b8fbad1c53c2054 (diff)
all remove functions now invalidate the RNA objects passed, to help script authors to avoid bugs with accessing removed data.
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index df278e7cf16..c29537378dd 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -497,24 +497,28 @@ static bConstraint *rna_PoseChannel_constraints_new(bPoseChannel *pchan, int typ
return add_pose_constraint(NULL, pchan, NULL, type);
}
-static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, bConstraint *con)
+static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, PointerRNA *con_ptr)
{
+ bConstraint *con = con_ptr->data;
+ const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
+ Object *ob = (Object *)id;
+
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;
}
- else {
- Object *ob = (Object *)id;
- const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
- remove_constraint(&pchan->constraints, con);
- ED_object_constraint_update(ob);
- constraints_set_active(&pchan->constraints, NULL);
- WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, id);
+ remove_constraint(&pchan->constraints, con);
+ RNA_POINTER_INVALIDATE(con_ptr);
- if (is_ik) {
- BIK_clear_data(ob->pose);
- }
+ ED_object_constraint_update(ob);
+
+ constraints_set_active(&pchan->constraints, NULL); /* XXX, is this really needed? - Campbell */
+
+ WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, id);
+
+ if (is_ik) {
+ BIK_clear_data(ob->pose);
}
}
@@ -727,7 +731,8 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
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);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_pose_channel(BlenderRNA *brna)