[Bf-blender-cvs] [9bd97e62ade] blender-v3.0-release: Fix T92464: Operators fail after opening blend files via an operator

Campbell Barton noreply at git.blender.org
Tue Nov 2 12:03:24 CET 2021


Commit: 9bd97e62ade417f6b4025acbad46802c3e7e5683
Author: Campbell Barton
Date:   Tue Nov 2 21:57:23 2021 +1100
Branches: blender-v3.0-release
https://developer.blender.org/rB9bd97e62ade417f6b4025acbad46802c3e7e5683

Fix T92464: Operators fail after opening blend files via an operator

Operators such as setting the object mode failed after calling
WM_OT_open_mainfile from Python.

Keep the window after loading a file outside the main event loop.

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

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

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

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 67222cc07f9..ff9b56d7859 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -769,6 +769,18 @@ static void wm_file_read_post(bContext *C, const struct wmFileReadPost_Params *p
       WM_toolsystem_init(C);
     }
   }
+
+  /* Keep last. */
+  if (use_data) {
+    if (!G.background) {
+      /* Special case, when calling indirectly (from a Python script for example),
+       * the event loop wont run again to set the active window.
+       * Set the window here to allow scripts to continue running other operations, see: T92464. */
+      if (wm->op_undo_depth > 0) {
+        CTX_wm_window_set(C, wm->windows.first);
+      }
+    }
+  }
 }
 
 /** \} */



More information about the Bf-blender-cvs mailing list