From e4fbc8fc8ddf5c212146fa90c38437389ef25db5 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 20 Apr 2015 12:28:50 +1200 Subject: Fix: Changing actions in the Action Editor using the Browse dropdown should happen in tweakmode When a NLA strip is being tweaked, it should not be possible to use the Action Editor to change the action that it uses. Instead of changing the action in tweakmode, it now exits tweakmode first before doing so. --- source/blender/makesrna/intern/rna_space.c | 34 +++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 8e3c4e5e877..300752d8cf5 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -237,6 +237,7 @@ static EnumPropertyItem buttons_texture_context_items[] = { #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_nla.h" #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" @@ -1223,17 +1224,34 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *UNUSED(bmain), Scene *s } /* set action */ + // FIXME: this overlaps a lot with the BKE_animdata_set_action() API method if (adt) { - /* fix id-count of action we're replacing */ - if (adt->action) { - id_us_min(&adt->action->id); + /* Don't do anything if old and new actions are the same... */ + if (adt->action != saction->action) { + /* NLA Tweak Mode needs special handling... */ + if (adt->flag & ADT_NLA_EDIT_ON) { + /* Exit editmode first - we cannot change actions while in tweakmode + * NOTE: This will clear the action ref properly + */ + BKE_nla_tweakmode_exit(adt); + + /* Assign new action, and adjust the usercounts accordingly */ + adt->action = saction->action; + id_us_plus(&adt->action->id); + } + else { + /* fix id-count of action we're replacing */ + if (adt->action) { + id_us_min(&adt->action->id); + } + + /* Assign new action, and adjust the usercounts accordingly */ + adt->action = saction->action; + id_us_plus(&adt->action->id); + } } - /* assign new action, and adjust the usercounts accordingly */ - adt->action = saction->action; - id_us_plus(&adt->action->id); - - /* force update of animdata */ + /* Force update of animdata */ adt->recalc |= ADT_RECALC_ANIM; } -- cgit v1.2.3