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:
authorJoshua Leung <aligorith@gmail.com>2010-05-05 04:44:42 +0400
committerJoshua Leung <aligorith@gmail.com>2010-05-05 04:44:42 +0400
commitbfca6d8f75d6b3a7a096c4918ed4137f434dff5d (patch)
treeda70fcf2b9d6495b11d51e10f01c39a50ce08237 /source/blender/editors/object/object_constraint.c
parent96aa9f7002aa2d87b815a73f8aa86cc9b1fdf9e7 (diff)
Bugfix #22244: Crash on using ops.constraint.childof_set_inverse and childOf_clear_inverse incorrectly
Adding some NULL checks to all the constraint operators. This is not ideal, but at least the crashes are gone now. More work is needed to properly fix this...
Diffstat (limited to 'source/blender/editors/object/object_constraint.c')
-rw-r--r--source/blender/editors/object/object_constraint.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 0748da6eae5..d9d04cb3247 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -527,8 +527,12 @@ static int stretchto_reset_exec (bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_STRETCHTO);
- bStretchToConstraint *data= (bStretchToConstraint *)con->data;
-
+ bStretchToConstraint *data= (con) ? (bStretchToConstraint *)con->data : NULL;
+
+ /* despite 3 layers of checks, we may still not be able to find a constraint */
+ if (data == NULL)
+ return OPERATOR_CANCELLED;
+
/* just set original length to 0.0, which will cause a reset on next recalc */
data->orglength = 0.0f;
ED_object_constraint_update(ob);
@@ -566,7 +570,11 @@ static int limitdistance_reset_exec (bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_DISTLIMIT);
- bDistLimitConstraint *data= (bDistLimitConstraint *)con->data;
+ bDistLimitConstraint *data= (con) ? (bDistLimitConstraint *)con->data : NULL;
+
+ /* despite 3 layers of checks, we may still not be able to find a constraint */
+ if (data == NULL)
+ return OPERATOR_CANCELLED;
/* just set original length to 0.0, which will cause a reset on next recalc */
data->dist = 0.0f;
@@ -601,22 +609,19 @@ void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot)
}
/* ------------- Child-Of Constraint ------------------ */
-#if 0 // unused
-static int childof_poll(bContext *C)
-{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_ChildOfConstraint);
- return (ptr.id.data && ptr.data);
-}
-#endif
/* ChildOf Constraint - set inverse callback */
static int childof_set_inverse_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_CHILDOF);
- bChildOfConstraint *data= (bChildOfConstraint *)con->data;
+ bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL;
bPoseChannel *pchan= NULL;
-
+
+ /* despite 3 layers of checks, we may still not be able to find a constraint */
+ if (data == NULL)
+ return OPERATOR_CANCELLED;
+
/* try to find a pose channel */
// TODO: get from context instead?
if (ob && ob->pose)
@@ -694,7 +699,7 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_CHILDOF);
- bChildOfConstraint *data= (bChildOfConstraint *)con->data;
+ bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL;
/* simply clear the matrix */
unit_m4(data->invmat);