Action Editor "Browse" Fix: Stash active action if nothing else uses it

Following the initial action management commits for 2.74, blurrymind pointed out a
problematic workflow involving the "Browse Action" dropdown in the Action Editor
which would lead to actions being accidentally lost. Namely, it turns out that
game animators frequently flip between different actions from the Browse menu while
working.

While the new up/down operators and/or other NLA based tools are better suited to this
without the problems of actions getting lost, some additional precautions were needed
for the Browse menu as well. So now, if the active action will have no users as a result
of the switch (i.e. it was a new action, and the user is checking on a previous action
via the Browse menu), this action will now get stashed. This workflow is not perfect though,
as there is the problem of the stashed action strips not reflecting the actions they reference.
This commit is contained in:
Joshua Leung 2015-04-20 17:21:05 +12:00
parent 689241b6e5
commit a0e1b6573a
1 changed files with 18 additions and 1 deletions

View File

@ -1240,9 +1240,26 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *UNUSED(bmain), Scene *s
id_us_plus((ID *)adt->action);
}
else {
/* fix id-count of action we're replacing */
/* Handle old action... */
if (adt->action) {
/* Fix id-count of action we're replacing */
id_us_min(&adt->action->id);
/* To prevent data loss (i.e. if users flip between actions using the Browse menu),
* stash this action if nothing else uses it.
*
* EXCEPTION:
* This callback runs when unlinking actions. In that case, we don't want to
* stash the action, as the user is signalling that they want to detach it.
* This can be reviewed again later, but it could get annoying if we keep these instead.
*/
if ((adt->action->id.us <= 0) && (saction->action != NULL)) {
/* XXX: Things here get dodgy if this action is only partially completed,
* and the user then uses the browse menu to get back to this action,
* assigning it as the active action (i.e. the stash strip gets out of sync)
*/
BKE_nla_action_stash(adt);
}
}
/* Assign new action, and adjust the usercounts accordingly */