[Bf-blender-cvs] [3017585ebfe] master: View 3D: the select operator now uses the cancel flag on failure

Campbell Barton noreply at git.blender.org
Thu Mar 17 06:47:31 CET 2022


Commit: 3017585ebfe84852f6969493badc77e27fdb8b54
Author: Campbell Barton
Date:   Thu Mar 17 16:22:33 2022 +1100
Branches: master
https://developer.blender.org/rB3017585ebfe84852f6969493badc77e27fdb8b54

View 3D: the select operator now uses the cancel flag on failure

Needed so mapping selection to click doesn't pass the click event
through to setting the 3D cursor for e.g.

While this doesn't happen with the default key-map, setting selection
to LMB-click would set the 3D cursor as well (when the selection
fell through to nothing).

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

M	source/blender/editors/space_view3d/view3d_select.c
M	source/blender/windowmanager/intern/wm_operator_utils.c

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

diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 6a524be3b9e..f635bcf52b8 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2832,13 +2832,16 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
     changed = ed_object_select_pick(C, mval, &params, center, enumerate, object);
   }
 
+  /* Pass-through flag may be cleared, see #WM_operator_flag_only_pass_through_on_press. */
+
   /* Pass-through allows tweaks
    * FINISHED to signal one operator worked */
   if (changed) {
     WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
     return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED;
   }
-  return OPERATOR_PASS_THROUGH; /* nothing selected, just passthrough */
+  /* Nothing selected, just passthrough. */
+  return OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED;
 }
 
 static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
diff --git a/source/blender/windowmanager/intern/wm_operator_utils.c b/source/blender/windowmanager/intern/wm_operator_utils.c
index 5a817075cd5..bde072bf000 100644
--- a/source/blender/windowmanager/intern/wm_operator_utils.c
+++ b/source/blender/windowmanager/intern/wm_operator_utils.c
@@ -32,9 +32,15 @@
 
 int WM_operator_flag_only_pass_through_on_press(int retval, const struct wmEvent *event)
 {
-  if ((event->val != KM_PRESS) &&
-      ((retval & OPERATOR_PASS_THROUGH) && (retval & OPERATOR_FINISHED))) {
-    retval &= ~OPERATOR_PASS_THROUGH;
+  if (event->val != KM_PRESS) {
+    if (retval & OPERATOR_PASS_THROUGH) {
+      /* Operators that use this function should either finish or cancel,
+       * otherwise non-press events will be passed through to other key-map items. */
+      BLI_assert((retval & ~OPERATOR_PASS_THROUGH) != 0);
+      if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) {
+        retval &= ~OPERATOR_PASS_THROUGH;
+      }
+    }
   }
   return retval;
 }



More information about the Bf-blender-cvs mailing list