Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratik Borhade <PratikPB2123>2022-04-05 13:13:03 +0300
committerCampbell Barton <campbell@blender.org>2022-04-05 13:30:00 +0300
commitd00de988c36a6bde9bccdd75cd544085df2d472c (patch)
tree1b3f13b45d75da53c014549334baf463df6aa7d4 /source/blender/editors/space_graph
parentd88b821d285e275240ad9ec52921e409cb6a5d52 (diff)
WM: avoid unnecessary undo step creation when duplicating
Calling duplicate operation without selecting anything registers an undo step. If nothing is selected (keyframe, curve, object, etc.), cancel the operator execution to prevent undo push. Patch improves following operators: - ACTION_OT_duplicate - GPENCIL_OT_duplicate - GRAPH_OT_duplicate - MESH_OT_duplicate - NODE_OT_duplicate - OBJECT_OT_duplicate Reviewed By: campbellbarton Ref D14511
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r--source/blender/editors/space_graph/graph_edit.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index bc82e7e20c2..2083a26f638 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -623,11 +623,12 @@ void GRAPH_OT_paste(wmOperatorType *ot)
/** \name Duplicate Keyframes Operator
* \{ */
-static void duplicate_graph_keys(bAnimContext *ac)
+static bool duplicate_graph_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
+ bool changed = false;
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT |
@@ -636,13 +637,15 @@ static void duplicate_graph_keys(bAnimContext *ac)
/* Loop through filtered data and delete selected keys. */
for (ale = anim_data.first; ale; ale = ale->next) {
- duplicate_fcurve_keys((FCurve *)ale->key_data);
+ changed |= duplicate_fcurve_keys((FCurve *)ale->key_data);
ale->update |= ANIM_UPDATE_DEFAULT;
}
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
+
+ return changed;
}
/* ------------------- */
@@ -657,7 +660,9 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
}
/* Duplicate keyframes. */
- duplicate_graph_keys(&ac);
+ if (!duplicate_graph_keys(&ac)) {
+ return OPERATOR_CANCELLED;
+ }
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);