[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26171] trunk/blender/source/blender/ blenkernel/intern/idprop.c: Fix bug in IDP_ReplaceGroupInGroup ( it would sometimes add the same property twice).

Martin Poirier theeth at yahoo.com
Thu Jan 21 22:01:18 CET 2010


Revision: 26171
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26171
Author:   theeth
Date:     2010-01-21 22:01:18 +0100 (Thu, 21 Jan 2010)

Log Message:
-----------
Fix bug in IDP_ReplaceGroupInGroup (it would sometimes add the same property twice).

Also simplify some other loops.

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

Modified: trunk/blender/source/blender/blenkernel/intern/idprop.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/idprop.c	2010-01-21 20:45:45 UTC (rev 26170)
+++ trunk/blender/source/blender/blenkernel/intern/idprop.c	2010-01-21 21:01:18 UTC (rev 26171)
@@ -392,13 +392,12 @@
 {
 	IDProperty *loop, *prop;
 	for (prop=src->data.group.first; prop; prop=prop->next) {
-		IDProperty *copy = IDP_CopyProperty(prop);
-
 		for (loop=dest->data.group.first; loop; loop=loop->next) {
 			if (BSTR_EQ(loop->name, prop->name)) {
-				if (loop->next) BLI_insertlinkbefore(&dest->data.group, loop->next, copy);
-				else BLI_addtail(&dest->data.group, copy);
+				IDProperty *copy = IDP_CopyProperty(prop);
 
+				BLI_insertlink(&dest->data.group, loop, copy);
+
 				BLI_remlink(&dest->data.group, loop);
 				IDP_FreeProperty(loop);
 				MEM_freeN(loop);
@@ -406,8 +405,12 @@
 			}
 		}
 
-		dest->len++;
-		BLI_addtail(&dest->data.group, copy);
+		/* only add at end if not added yet */
+		if (loop == NULL) {
+			IDProperty *copy = IDP_CopyProperty(prop);
+			dest->len++;
+			BLI_addtail(&dest->data.group, copy);
+		}
 	}
 }
 /*
@@ -419,8 +422,7 @@
 	IDProperty *loop;
 	for (loop=group->data.group.first; loop; loop=loop->next) {
 		if (BSTR_EQ(loop->name, prop->name)) {
-			if (loop->next) BLI_insertlinkbefore(&group->data.group, loop->next, prop);
-			else BLI_addtail(&group->data.group, prop);
+			BLI_insertlink(&group->data.group, loop, prop);
 			
 			BLI_remlink(&group->data.group, loop);
 			IDP_FreeProperty(loop);
@@ -513,14 +515,12 @@
   direct data.*/
 static void IDP_FreeGroup(IDProperty *prop)
 {
-	IDProperty *loop, *next;
-	for (loop=prop->data.group.first; loop; loop=next)
+	IDProperty *loop;
+	for (loop=prop->data.group.first; loop; loop=loop->next)
 	{
-		next = loop->next;
-		BLI_remlink(&prop->data.group, loop);
 		IDP_FreeProperty(loop);
-		MEM_freeN(loop);
 	}
+	BLI_freelistN(&prop->data.group);
 }
 
 





More information about the Bf-blender-cvs mailing list