From 9621d626a0484d19e2c18e57cbdd5f9c24c827f4 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 6 Jun 2009 05:06:46 +0000 Subject: [PATCH] NLA SoC: Various user-counts and file IO bugfixes for tweaking actions... --- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/nla.c | 5 ++++- source/blender/blenloader/intern/readfile.c | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index fb4c2663c3c..390efc5ced4 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -154,7 +154,7 @@ AnimData *BKE_copy_animdata (AnimData *adt) // XXX review this... it might not be optimal behaviour yet... //id_us_plus((ID *)dadt->action); dadt->action= copy_action(adt->action); - dadt->tmpact= copy_action(adt->action); + dadt->tmpact= copy_action(adt->tmpact); /* duplicate NLA data */ copy_nladata(&dadt->nla_tracks, &adt->nla_tracks); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index d3a01b6d610..9acbad32a42 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -675,11 +675,12 @@ short BKE_nla_tweakmode_enter (AnimData *adt) /* handle AnimData level changes: * - 'real' active action to temp storage (no need to change user-counts) - * - action of active strip set to be the 'active action' + * - action of active strip set to be the 'active action', and have its usercount incremented * - editing-flag for this AnimData block should also get turned on (for more efficient restoring) */ adt->tmpact= adt->action; adt->action= activeStrip->act; + id_us_plus(&activeStrip->act->id); adt->flag |= ADT_NLA_EDIT_ON; /* done! */ @@ -706,10 +707,12 @@ void BKE_nla_tweakmode_exit (AnimData *adt) nlt->flag &= ~NLATRACK_DISABLED; /* handle AnimData level changes: + * - 'temporary' active action needs its usercount decreased, since we're removing this reference * - 'real' active action is restored from storage * - storage pointer gets cleared (to avoid having bad notes hanging around) * - editing-flag for this AnimData block should also get turned off */ + if (adt->action) adt->action->id.us--; adt->action= adt->tmpact; adt->tmpact= NULL; adt->flag &= ~ADT_NLA_EDIT_ON; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e3869d4bc8a..c306f5bcde4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1896,6 +1896,7 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) /* link action data */ adt->action= newlibadr_us(fd, id->lib, adt->action); + adt->tmpact= newlibadr_us(fd, id->lib, adt->tmpact); /* link drivers */ lib_link_fcurves(fd, id, &adt->drivers); @@ -9406,6 +9407,7 @@ static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt) /* own action */ expand_doit(fd, mainvar, adt->action); + expand_doit(fd, mainvar, adt->tmpact); /* drivers - assume that these F-Curves have driver data to be in this list... */ for (fcd= adt->drivers.first; fcd; fcd= fcd->next) {