[Bf-blender-cvs] [b1c4db1fbe8] blender-v2.83-release: Fix T76484: Infinite event handling when loading with load_ui=False

Campbell Barton noreply at git.blender.org
Fri May 8 10:56:06 CEST 2020


Commit: b1c4db1fbe8075e57c7c174ffd07481c3d56fee4
Author: Campbell Barton
Date:   Fri May 8 18:41:15 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rBb1c4db1fbe8075e57c7c174ffd07481c3d56fee4

Fix T76484: Infinite event handling when loading with load_ui=False

When loading a file from the Python console with load_ui=False,
the event was never freed from the queue causing the command
to continuously be executed.

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

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

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

diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 8b8c1b90dc9..cb16550717b 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -3110,6 +3110,25 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event)
   }
 }
 
+/**
+ * Account for the special case when events are being handled and a file is loaded.
+ * In this case event handling exits early, however when "Load UI" is disabled
+ * the even will still be in #wmWindow.queue.
+ *
+ * Without this it's possible to continuously handle the same event, see: T76484.
+ */
+static void wm_event_free_and_remove_from_queue_if_valid(wmEvent *event)
+{
+  LISTBASE_FOREACH (wmWindowManager *, wm, &G_MAIN->wm) {
+    LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+      if (BLI_remlink_safe(&win->queue, event)) {
+        wm_event_free(event);
+        return;
+      }
+    }
+  }
+}
+
 /* called in main loop */
 /* goes over entire hierarchy:  events -> window -> screen -> area -> region */
 void wm_event_do_handlers(bContext *C)
@@ -3232,6 +3251,7 @@ void wm_event_do_handlers(bContext *C)
 
       /* fileread case */
       if (CTX_wm_window(C) == NULL) {
+        wm_event_free_and_remove_from_queue_if_valid(event);
         return;
       }
 
@@ -3306,6 +3326,7 @@ void wm_event_do_handlers(bContext *C)
 
                   /* fileread case (python), [#29489] */
                   if (CTX_wm_window(C) == NULL) {
+                    wm_event_free_and_remove_from_queue_if_valid(event);
                     return;
                   }
 
@@ -3340,6 +3361,7 @@ void wm_event_do_handlers(bContext *C)
 
           /* fileread case */
           if (CTX_wm_window(C) == NULL) {
+            wm_event_free_and_remove_from_queue_if_valid(event);
             return;
           }
         }



More information about the Bf-blender-cvs mailing list