[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26911] trunk/blender/source/blender/ blenkernel: copy animdata and id-props when copying material node tree' s to avoid double memory frees or node trees sharing animdata when they shouldnt .
Campbell Barton
ideasman42 at gmail.com
Mon Feb 15 09:50:05 CET 2010
Revision: 26911
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26911
Author: campbellbarton
Date: 2010-02-15 09:50:04 +0100 (Mon, 15 Feb 2010)
Log Message:
-----------
copy animdata and id-props when copying material node tree's to avoid double memory frees or node trees sharing animdata when they shouldnt.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_library.h
trunk/blender/source/blender/blenkernel/intern/library.c
trunk/blender/source/blender/blenkernel/intern/node.c
Modified: trunk/blender/source/blender/blenkernel/BKE_library.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_library.h 2010-02-15 08:29:01 UTC (rev 26910)
+++ trunk/blender/source/blender/blenkernel/BKE_library.h 2010-02-15 08:50:04 UTC (rev 26911)
@@ -42,6 +42,7 @@
void *alloc_libblock(struct ListBase *lb, short type, const char *name);
void *copy_libblock(void *rt);
+void copy_libblock_data(struct ID *id, const struct ID *id_from);
void id_lib_extern(struct ID *id);
void id_us_plus(struct ID *id);
Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c 2010-02-15 08:29:01 UTC (rev 26910)
+++ trunk/blender/source/blender/blenkernel/intern/library.c 2010-02-15 08:50:04 UTC (rev 26911)
@@ -653,7 +653,17 @@
}
}
-/* used everywhere in blenkernel and text.c */
+/* material nodes use this since they are not treated as libdata */
+void copy_libblock_data(ID *id, const ID *id_from)
+{
+ if (id_from->properties)
+ id->properties = IDP_CopyProperty(id_from->properties);
+
+ /* the duplicate should get a copy of the animdata */
+ id_copy_animdata(id);
+}
+
+/* used everywhere in blenkernel */
void *copy_libblock(void *rt)
{
ID *idn, *id;
@@ -679,11 +689,9 @@
id->newid= idn;
idn->flag |= LIB_NEW;
- if (id->properties) idn->properties = IDP_CopyProperty(id->properties);
+
+ copy_libblock_data(idn, id);
- /* the duplicate should get a copy of the animdata */
- id_copy_animdata(idn);
-
return idn;
}
Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c 2010-02-15 08:29:01 UTC (rev 26910)
+++ trunk/blender/source/blender/blenkernel/intern/node.c 2010-02-15 08:50:04 UTC (rev 26911)
@@ -1105,10 +1105,12 @@
/* is ntree part of library? */
for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next)
if(newtree==ntree) break;
- if(newtree)
+ if(newtree) {
newtree= copy_libblock(ntree);
- else
+ } else {
newtree= MEM_dupallocN(ntree);
+ copy_libblock_data(&newtree->id, &ntree->id); /* copy animdata and ID props */
+ }
newtree->nodes.first= newtree->nodes.last= NULL;
newtree->links.first= newtree->links.last= NULL;
}
More information about the Bf-blender-cvs
mailing list