[Bf-blender-cvs] [6047653ec04] master: Fix T63904: Remove Animation should remove empty actions from objects.

Alexander Gavrilov noreply at git.blender.org
Thu May 2 13:56:30 CEST 2019


Commit: 6047653ec04efbc556506adad835cc83eb4c7dcf
Author: Alexander Gavrilov
Date:   Thu May 2 14:51:43 2019 +0300
Branches: master
https://developer.blender.org/rB6047653ec04efbc556506adad835cc83eb4c7dcf

Fix T63904: Remove Animation should remove empty actions from objects.

===================================================================

M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/include/ED_anim_api.h

===================================================================

diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 40abf8a12bb..6e0277d5fff 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -649,14 +649,28 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
      * channel list that are empty, and linger around long after the data they
      * are for has disappeared (and probably won't come back).
      */
+    ANIM_remove_empty_action_from_animdata(adt);
+  }
+
+  /* free the F-Curve itself */
+  free_fcurve(fcu);
+}
+
+/* If the action has no F-Curves, unlink it from AnimData if it did not
+ * come from a NLA Strip being tweaked. */
+bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt)
+{
+  if (adt->action != NULL) {
+    bAction *act = adt->action;
+
     if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
       id_us_min(&act->id);
       adt->action = NULL;
+      return true;
     }
   }
 
-  /* free the F-Curve itself */
-  free_fcurve(fcu);
+  return false;
 }
 
 /* ************************************************************************** */
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 9b2e1af55e4..a0433b49b16 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -2209,6 +2209,11 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
           changed = true;
         }
       }
+
+      /* Delete the action itself if it is empty. */
+      if (ANIM_remove_empty_action_from_animdata(adt)) {
+        changed = true;
+      }
     }
   }
   CTX_DATA_END;
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index d314e9b4ca6..d947322f708 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -612,6 +612,9 @@ void ANIM_set_active_channel(bAnimContext *ac,
  * as appropriate according to animation context */
 void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, struct AnimData *adt, struct FCurve *fcu);
 
+/* Unlink the action from animdata if it's empty. */
+bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt);
+
 /* ************************************************ */
 /* DRAWING API */
 /* anim_draw.c */



More information about the Bf-blender-cvs mailing list