diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-09-30 08:59:14 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-09-30 08:59:14 +0400 |
commit | 2a21c1acbef1920a7bf177974119800c23a993c7 (patch) | |
tree | f1cfeb8544f0c31b1a198455e7349f57f2f417c1 /source/blender/blenkernel/intern/library.c | |
parent | 8b6f5c171da4d9b165c5ba0628f0302430dbed2b (diff) |
Animato: Bugfixes
* #19501: Only the first user of multi-user IPO's were getting converted to AnimData.
Now, this AnimData gets converted multiple times - once for each user. This will mean that multi-user actions will no longer be multi-user after conversion though, although this could be fixed manually if there really is such a need.
* #19503: Nasty memory leaks when duplicating objects with AnimData
Fixed a few little oversights made when coding the copying code for NLA-data (which resulted in exponential copying-loops of doom), and sanitised the AnimData copying code for ID-blocks to be simpler to manage.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 45869a317e8..0f65be207d9 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -640,42 +640,15 @@ void *alloc_libblock(ListBase *lb, short type, const char *name) } /* by spec, animdata is first item after ID */ -/* we still read ->adt itself, to ensure compiler warns when it doesnt exist */ +/* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */ static void id_copy_animdata(ID *id) { - switch(GS(id->name)) { - case ID_OB: - ((Object *)id)->adt= BKE_copy_animdata(((Object *)id)->adt); - break; - case ID_CU: - ((Curve *)id)->adt= BKE_copy_animdata(((Curve *)id)->adt); - break; - case ID_CA: - ((Camera *)id)->adt= BKE_copy_animdata(((Camera *)id)->adt); - break; - case ID_KE: - ((Key *)id)->adt= BKE_copy_animdata(((Key *)id)->adt); - break; - case ID_LA: - ((Lamp *)id)->adt= BKE_copy_animdata(((Lamp *)id)->adt); - break; - case ID_MA: - ((Material *)id)->adt= BKE_copy_animdata(((Material *)id)->adt); - break; - case ID_NT: - ((bNodeTree *)id)->adt= BKE_copy_animdata(((bNodeTree *)id)->adt); - break; - case ID_SCE: - ((Scene *)id)->adt= BKE_copy_animdata(((Scene *)id)->adt); - break; - case ID_TE: - ((Tex *)id)->adt= BKE_copy_animdata(((Tex *)id)->adt); - break; - case ID_WO: - ((World *)id)->adt= BKE_copy_animdata(((World *)id)->adt); - break; - } + AnimData *adt= BKE_animdata_from_id(id); + if (adt) { + IdAdtTemplate *iat = (IdAdtTemplate *)id; + iat->adt= BKE_copy_animdata(iat->adt); + } } /* used everywhere in blenkernel and text.c */ @@ -705,8 +678,9 @@ void *copy_libblock(void *rt) id->newid= idn; idn->flag |= LIB_NEW; if (id->properties) idn->properties = IDP_CopyProperty(id->properties); - - id_copy_animdata(id); + + /* the duplicate should get a copy of the animdata */ + id_copy_animdata(idn); return idn; } |