diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-01-17 14:38:14 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-01-17 14:38:14 +0300 |
commit | 0aaae43748205a4945fd8a1588a2f118a6d4edad (patch) | |
tree | f665495e2b19ab8332f3f9e6df8b6d852977fbcb /source/blender/editors/space_graph/graph_edit.c | |
parent | c38ebf93e356a97b3013b075e1d98268df891809 (diff) |
Simplified GRAPH_OT_driver_delete_invalid after feedback @aligorith
By adding the ANIMFILTER_NODUPLIS flag to the filter it'll only be
processing each F-Curve once, which means we can remove while iterating.
This also solves a potential issue when a datablock has a driver and is
shared among multiple objects.
Diffstat (limited to 'source/blender/editors/space_graph/graph_edit.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 396dd93ebd9..69feae6ee24 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -2746,19 +2746,12 @@ void GRAPH_OT_driver_variables_paste(wmOperatorType *ot) } /* ************************************************************************** */ -typedef struct InvalidDriverInfo { - struct InvalidDriverInfo *next, *prev; - ID *id; - FCurve *fcu; -} InvalidDriverInfo; static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; - ListBase to_delete = {NULL, NULL}; bAnimListElem *ale; - InvalidDriverInfo *idi; int filter; bool ok = false; unsigned int deleted = 0; @@ -2770,7 +2763,7 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) /* NOTE: we might need a scene update to evaluate the driver flags */ /* filter data */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* find invalid drivers */ @@ -2783,17 +2776,7 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) continue; } - /* remember in a separate list so we don't iterate over the same collection we modify */ - idi = MEM_callocN(sizeof(InvalidDriverInfo), "invalid driver info"); - BLI_assert(idi != NULL); - idi->id = ale->id; - idi->fcu = fcu; - BLI_addtail(&to_delete, idi); - } - - /* delete invalid drivers */ - for (idi = to_delete.first; idi; idi = idi->next) { - ok |= ANIM_remove_driver(op->reports, idi->id, idi->fcu->rna_path, idi->fcu->array_index, 0); + ok |= ANIM_remove_driver(op->reports, ale->id, fcu->rna_path, fcu->array_index, 0); if (!ok) { break; } @@ -2801,7 +2784,6 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) } /* cleanup */ - BLI_freelistN(&to_delete); ANIM_animdata_freelist(&anim_data); if (deleted > 0) { |