[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12805] trunk/blender/source/blender/ blenkernel/intern/constraint.c: Constraints Bugfix:

Joshua Leung aligorith at gmail.com
Thu Dec 6 11:20:03 CET 2007


Revision: 12805
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12805
Author:   aligorith
Date:     2007-12-06 11:20:03 +0100 (Thu, 06 Dec 2007)

Log Message:
-----------
Constraints Bugfix:

IK-constraint "flush_targets" function was causing segfaults on debug builds from certain MSVC compilers. 

The cause of this, is that ct is freed in the SINGLETARGET_FLUSH_TARS macro already, but ct is accessed in the following line to get the next target (ct= ct->next). Caused by brecht's commit for the pole-target stuff for IK-constraint.

Now the SINGLETARGET_FLUSH_TARS macro, and the SINGLETARGETNS_FLUSH_TARS macro will correctly advance the location that ct points to. 

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	2007-12-06 09:41:46 UTC (rev 12804)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2007-12-06 10:20:03 UTC (rev 12805)
@@ -874,12 +874,14 @@
 
 /* This following macro should be used for all standard single-target *_flush_tars functions
  * to save typing and reduce maintainance woes.
+ * Note: the pointer to ct will be changed to point to the next in the list (as it gets removed)
  * (Hopefully all compilers will be happy with the lines with just a space on them. Those are
  *  really just to help this code easier to read)
  */
 #define SINGLETARGET_FLUSH_TARS(con, datatar, datasubtarget, ct, list, nocopy) \
 	{ \
 		if (ct) { \
+			bConstraintTarget *ctn = ct->next; \
 			if (nocopy == 0) { \
 				datatar= ct->tar; \
 				strcpy(datasubtarget, ct->subtarget); \
@@ -887,23 +889,27 @@
 			} \
 			 \
 			BLI_freelinkN(list, ct); \
+			ct= ctn; \
 		} \
 	}
 	
 /* This following macro should be used for all standard single-target *_flush_tars functions
- * to save typing and reduce maintainance woes. It does not do the subtarget related operations
+ * to save typing and reduce maintainance woes. It does not do the subtarget related operations.
+ * Note: the pointer to ct will be changed to point to the next in the list (as it gets removed)
  * (Hopefully all compilers will be happy with the lines with just a space on them. Those are
  *  really just to help this code easier to read)
  */
 #define SINGLETARGETNS_FLUSH_TARS(con, datatar, ct, list, nocopy) \
 	{ \
 		if (ct) { \
+			bConstraintTarget *ctn = ct->next; \
 			if (nocopy == 0) { \
 				datatar= ct->tar; \
 				con->tarspace= ct->space; \
 			} \
 			 \
 			BLI_freelinkN(list, ct); \
+			ct= ctn; \
 		} \
 	}
  
@@ -1214,7 +1220,6 @@
 		
 		/* the following macro is used for all standard single-target constraints */
 		SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
-		ct= ct->next;
 		SINGLETARGET_FLUSH_TARS(con, data->poletar, data->polesubtarget, ct, list, nocopy)
 	}
 }





More information about the Bf-blender-cvs mailing list