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/object/object_add.cc
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/object/object_add.cc')
-rw-r--r--source/blender/editors/object/object_add.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc
index 6a7920d4d75..ba11483722e 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -3564,6 +3564,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
const bool linked = RNA_boolean_get(op->ptr, "linked");
const eDupli_ID_Flags dupflag = (linked) ? (eDupli_ID_Flags)0 : (eDupli_ID_Flags)U.dupflag;
+ bool changed = false;
/* We need to handle that here ourselves, because we may duplicate several objects, in which case
* we also want to remap pointers between those... */
@@ -3582,6 +3583,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
* the list is made in advance */
ED_object_base_select(base, BA_DESELECT);
ED_object_base_select(basen, BA_SELECT);
+ changed = true;
if (basen == nullptr) {
continue;
@@ -3598,6 +3600,10 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
+ if (!changed) {
+ return OPERATOR_CANCELLED;
+ }
+
/* Note that this will also clear newid pointers and tags. */
copy_object_set_idnew(C);