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>2012-05-06 05:03:51 +0400
committerJoshua Leung <aligorith@gmail.com>2012-05-06 05:03:51 +0400
commit2554a6788925b52a70ec9f90e33a57a373b1d04f (patch)
tree357a80bdf309f98ff07473b6bfb89f3320a27e3f /source/blender/blenkernel
parentc91cee2bb9fd3a8ddef3355534971782e8e6f519 (diff)
Deleting action constraints (and a few others) now adjusts the usercounts of
their referenced data correctly
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/constraint.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 66209e8a924..0ce3807fecb 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4318,17 +4318,31 @@ bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con)
/* ---------- Data Management ------- */
+/* helper function for free_constraint_data() - unlinks references */
+static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData))
+{
+ if (*idpoin && isReference)
+ id_us_min(*idpoin);
+}
+
/* Free data of a specific constraint if it has any info.
* be sure to run BIK_clear_data() when freeing an IK constraint,
- * unless DAG_scene_sort is called. */
+ * unless DAG_scene_sort is called.
+ */
void free_constraint_data(bConstraint *con)
{
if (con->data) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
- /* perform any special freeing constraint may have */
- if (cti && cti->free_data)
- cti->free_data(con);
+ if (cti) {
+ /* perform any special freeing constraint may have */
+ if (cti->free_data)
+ cti->free_data(con);
+
+ /* unlink the referenced resources it uses */
+ if (cti->id_looper)
+ cti->id_looper(con, con_unlink_refs_cb, NULL);
+ }
/* free constraint data now */
MEM_freeN(con->data);