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
This commit is contained in:
@@ -118,11 +118,13 @@ void clear_fcurve_keys(FCurve *fcu)
|
||||
|
||||
/* ---------------- */
|
||||
|
||||
void duplicate_fcurve_keys(FCurve *fcu)
|
||||
bool duplicate_fcurve_keys(FCurve *fcu)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
/* this can only work when there is an F-Curve, and also when there are some BezTriples */
|
||||
if (ELEM(NULL, fcu, fcu->bezt)) {
|
||||
return;
|
||||
return changed;
|
||||
}
|
||||
|
||||
for (int i = 0; i < fcu->totvert; i++) {
|
||||
@@ -135,7 +137,7 @@ void duplicate_fcurve_keys(FCurve *fcu)
|
||||
memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple));
|
||||
memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof(BezTriple) * (fcu->totvert - (i + 1)));
|
||||
fcu->totvert++;
|
||||
|
||||
changed = true;
|
||||
/* reassign pointers... (free old, and add new) */
|
||||
MEM_freeN(fcu->bezt);
|
||||
fcu->bezt = newbezt;
|
||||
@@ -148,6 +150,7 @@ void duplicate_fcurve_keys(FCurve *fcu)
|
||||
BEZT_SEL_ALL(&fcu->bezt[i]);
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
Reference in New Issue
Block a user