From 7369c4f4d50ee02d8ad574bbb1a3320626e1bed3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 30 Apr 2015 22:50:31 +1200 Subject: Code Cleanup: Simplify Clear Keyframes operator's code On second thought, the previous commit was just adding additional complexity which wasn't needed, as the operator was wasting effort by doing this looping itself. --- source/blender/editors/animation/keyframing.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 08b1889aff6..4e1e9320a37 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1865,7 +1865,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) PropertyRNA *prop = NULL; char *path; short success = 0; - int a, index, length; + int index; const bool all = RNA_boolean_get(op->ptr, "all"); /* try to insert keyframe using property retrieved from UI */ @@ -1876,28 +1876,11 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) if (path) { if (all) { - length = RNA_property_array_length(&ptr, prop); - - if (length) index = 0; - else length = 1; - } - else - length = 1; - - for (a = 0; a < length; a++) { - AnimData *adt = BKE_animdata_from_id(ptr.id.data); - - success += clear_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, 0); - - /* T44558 - Stop if there's no animdata anymore - * This is needed if only the first item in an array is keyed, - * and we're clearing for the whole array - */ - if (ELEM(NULL, adt, adt->action)) { - break; - } + /* -1 indicates operating on the entire array (or the property itself otherwise) */ + index = -1; } + success += clear_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, 0); MEM_freeN(path); } else if (G.debug & G_DEBUG) -- cgit v1.2.3