[Bf-blender-cvs] [99c798b8a62] master: Cleanup: centralize WM_gesture_end call

Campbell Barton noreply at git.blender.org
Thu Jan 9 01:10:56 CET 2020


Commit: 99c798b8a623fdf40d592a2b48304ebe77040f4a
Author: Campbell Barton
Date:   Thu Jan 9 10:36:53 2020 +1100
Branches: master
https://developer.blender.org/rB99c798b8a623fdf40d592a2b48304ebe77040f4a

Cleanup: centralize WM_gesture_end call

Prepare for adding extra logic on free (next).

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

M	source/blender/windowmanager/intern/wm_gesture_ops.c

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

diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index 5dd67355f54..4bd87b33a23 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -466,16 +466,17 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event)
   wmWindow *window = CTX_wm_window(C);
   wmGesture *gesture = window->tweak;
   rcti *rect = gesture->customdata;
-  int val;
+  bool gesture_end = false;
 
   switch (event->type) {
     case MOUSEMOVE:
-    case INBETWEEN_MOUSEMOVE:
+    case INBETWEEN_MOUSEMOVE: {
 
       rect->xmax = event->x - gesture->winrct.xmin;
       rect->ymax = event->y - gesture->winrct.ymin;
 
-      if ((val = wm_gesture_evaluate(gesture, event))) {
+      const int val = wm_gesture_evaluate(gesture, event);
+      if (val != 0) {
         wmEvent tevent;
 
         wm_event_init_from_window(window, &tevent);
@@ -499,16 +500,17 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event)
          * (which may be in the queue already), are handled in order, see T44740 */
         wm_event_add_ex(window, &tevent, event);
 
-        WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
+        gesture_end = true;
       }
 
       break;
+    }
 
     case LEFTMOUSE:
     case RIGHTMOUSE:
     case MIDDLEMOUSE:
       if (gesture->event_type == event->type) {
-        WM_gesture_end(C, gesture);
+        gesture_end = true;
 
         /* when tweak fails we should give the other keymap entries a chance */
 
@@ -518,10 +520,15 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event)
       break;
     default:
       if (!ISTIMER(event->type) && event->type != EVENT_NONE) {
-        WM_gesture_end(C, gesture);
+        gesture_end = true;
       }
       break;
   }
+
+  if (gesture_end) {
+    /* Frees gesture itself, and unregisters from window. */
+    WM_gesture_end(C, gesture);
+  }
 }
 
 /* standard tweak, called after window handlers passed on event */



More information about the Bf-blender-cvs mailing list