[Bf-blender-cvs] [0aaae437482] master: Simplified GRAPH_OT_driver_delete_invalid after feedback @aligorith

Sybren A. Stüvel noreply at git.blender.org
Wed Jan 17 12:38:27 CET 2018


Commit: 0aaae43748205a4945fd8a1588a2f118a6d4edad
Author: Sybren A. Stüvel
Date:   Wed Jan 17 12:38:14 2018 +0100
Branches: master
https://developer.blender.org/rB0aaae43748205a4945fd8a1588a2f118a6d4edad

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.

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

M	source/blender/editors/space_graph/graph_edit.c

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

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) {



More information about the Bf-blender-cvs mailing list