diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-03-06 13:21:01 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-03-06 13:22:25 +0300 |
commit | 6405aa4e9c73a2d51234b4e855bd5e8c1e4ba30f (patch) | |
tree | a402a9ff9f2b655cd7441ca3935cbdb0aa8bee90 /source/blender/blenkernel/intern/constraint.c | |
parent | 3f572fe7d25032a37770e71bda20eb6c4cd23a8b (diff) |
Fix access freed memory when doing constraints ID counter on main free
Basically just made constraints free function aware of possible do_id_users
argument, same as we've got for objects, object data and so on.
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 93f524a5439..c38a1239f12 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4370,7 +4370,7 @@ static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_re * be sure to run BIK_clear_data() when freeing an IK constraint, * unless DAG_relations_tag_update is called. */ -void BKE_constraint_free_data(bConstraint *con) +void BKE_constraint_free_data_ex(bConstraint *con, bool do_id_user) { if (con->data) { bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); @@ -4381,7 +4381,7 @@ void BKE_constraint_free_data(bConstraint *con) cti->free_data(con); /* unlink the referenced resources it uses */ - if (cti->id_looper) + if (do_id_user && cti->id_looper) cti->id_looper(con, con_unlink_refs_cb, NULL); } @@ -4390,19 +4390,28 @@ void BKE_constraint_free_data(bConstraint *con) } } +void BKE_constraint_free_data(bConstraint *con) +{ + BKE_constraint_free_data_ex(con, true); +} + /* Free all constraints from a constraint-stack */ -void BKE_constraints_free(ListBase *list) +void BKE_constraints_free_ex(ListBase *list, bool do_id_user) { bConstraint *con; /* Free constraint data and also any extra data */ for (con = list->first; con; con = con->next) - BKE_constraint_free_data(con); + BKE_constraint_free_data_ex(con, do_id_user); /* Free the whole list */ BLI_freelistN(list); } +void BKE_constraints_free(ListBase *list) +{ + BKE_constraints_free_ex(list, true); +} /* Remove the specified constraint from the given constraint stack */ bool BKE_constraint_remove(ListBase *list, bConstraint *con) |