[Bf-blender-cvs] [0cddc7e300f] master: WM: operator flag to check repeat/redo execution

Campbell Barton noreply at git.blender.org
Fri Jan 19 11:01:19 CET 2018


Commit: 0cddc7e300fd90cdc6dd8ca8dafca21e8ccfa8a9
Author: Campbell Barton
Date:   Fri Jan 19 21:07:43 2018 +1100
Branches: master
https://developer.blender.org/rB0cddc7e300fd90cdc6dd8ca8dafca21e8ccfa8a9

WM: operator flag to check repeat/redo execution

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

M	source/blender/makesdna/DNA_windowmanager_types.h
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/windowmanager/intern/wm_event_system.c

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

diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 06185a583bb..cf8dbdd8c63 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -398,13 +398,15 @@ enum {
 	/* low level flag so exec() operators can tell if they were invoked, use with care.
 	 * typically this shouldn't make any difference, but it rare cases its needed (see smooth-view) */
 	OP_IS_INVOKE = (1 << 0),
+	/* So we can detect if an operators exec() call is activated from an interactive repeat. */
+	OP_IS_REPEAT = (1 << 1),
 
 	/* When the cursor is grabbed */
-	OP_IS_MODAL_GRAB_CURSOR    = (1 << 1),
+	OP_IS_MODAL_GRAB_CURSOR    = (1 << 2),
 
 	/* allow modal operators to have the region under the cursor for their context
 	 * (the regiontype is maintained to prevent errors) */
-	OP_IS_MODAL_CURSOR_REGION = (1 << 2),
+	OP_IS_MODAL_CURSOR_REGION = (1 << 3),
 };
 
 #endif /* __DNA_WINDOWMANAGER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 5b4fe30aaef..265758eb5c3 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -1443,6 +1443,11 @@ static void rna_def_operator_options_runtime(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Invoke", "True when invoked (even if only the execute callbacks available)");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
+	prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_BOOLEAN);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_REPEAT);
+	RNA_def_property_ui_text(prop, "Repeat", "True when run from the redo panel");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
 	prop = RNA_def_property(srna, "use_cursor_region", PROP_BOOLEAN, PROP_BOOLEAN);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_MODAL_CURSOR_REGION);
 	RNA_def_property_ui_text(prop, "Focus Region", "Enable to use the region under the cursor for modal execution");
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index ed56586711d..61c144a63d4 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -802,14 +802,22 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons
 		return retval;
 	
 	if (op->type->exec) {
-		if (op->type->flag & OPTYPE_UNDO)
+		if (op->type->flag & OPTYPE_UNDO) {
 			wm->op_undo_depth++;
+		}
 
+		if (repeat) {
+			op->flag |= OP_IS_REPEAT;
+		}
 		retval = op->type->exec(C, op);
 		OPERATOR_RETVAL_CHECK(retval);
+		if (repeat) {
+			op->flag &= ~OP_IS_REPEAT;
+		}
 
-		if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
+		if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) {
 			wm->op_undo_depth--;
+		}
 	}
 	
 	/* XXX Disabled the repeat check to address part 2 of #31840.



More information about the Bf-blender-cvs mailing list