[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46332] trunk/blender/source/blender/ blenkernel/intern/constraint.c: Deleting action constraints ( and a few others) now adjusts the usercounts of

Joshua Leung aligorith at gmail.com
Sun May 6 03:03:54 CEST 2012


Revision: 46332
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46332
Author:   aligorith
Date:     2012-05-06 01:03:51 +0000 (Sun, 06 May 2012)
Log Message:
-----------
Deleting action constraints (and a few others) now adjusts the usercounts of
their referenced data correctly

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/constraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2012-05-05 21:28:12 UTC (rev 46331)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2012-05-06 01:03:51 UTC (rev 46332)
@@ -4318,17 +4318,31 @@
  
 /* ---------- 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);




More information about the Bf-blender-cvs mailing list