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/mesh/editmesh_tools.c
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/mesh/editmesh_tools.c')
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 1499742af54..0b2944657fd 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2014,6 +2014,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
view_layer, CTX_wm_view3d(C), &objects_len);
+ bool changed = false;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -2024,6 +2025,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
BMOperator bmop;
BMesh *bm = em->bm;
+ changed = true;
EDBM_op_init(em,
&bmop,
@@ -2058,16 +2060,16 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
}
MEM_freeN(objects);
- return OPERATOR_FINISHED;
+ return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static int edbm_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
WM_cursor_wait(true);
- edbm_duplicate_exec(C, op);
+ const int retval = edbm_duplicate_exec(C, op);
WM_cursor_wait(false);
- return OPERATOR_FINISHED;
+ return retval;
}
void MESH_OT_duplicate(wmOperatorType *ot)