[Bf-blender-cvs] [2ed847317e7] blender-v2.93-release: Fix crash running window operators in background mode

Campbell Barton noreply at git.blender.org
Fri Apr 30 07:09:02 CEST 2021


Commit: 2ed847317e7da8de86846766c54f40c5ee7cee73
Author: Campbell Barton
Date:   Fri Apr 30 14:16:50 2021 +1000
Branches: blender-v2.93-release
https://developer.blender.org/rB2ed847317e7da8de86846766c54f40c5ee7cee73

Fix crash running window operators in background mode

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

M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/screen_ops.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index b3205acb8ee..78c4c2a8eba 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -304,6 +304,7 @@ void ED_operatortypes_workspace(void);
 
 /* operators; context poll callbacks */
 bool ED_operator_screenactive(struct bContext *C);
+bool ED_operator_screenactive_nobackground(struct bContext *C);
 bool ED_operator_screen_mainwinactive(struct bContext *C);
 bool ED_operator_areaactive(struct bContext *C);
 bool ED_operator_regionactive(struct bContext *C);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 5cd4e8c353b..765877d6a8e 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -141,6 +141,14 @@ bool ED_operator_screenactive(bContext *C)
   return true;
 }
 
+bool ED_operator_screenactive_nobackground(bContext *C)
+{
+  if (G.background) {
+    return false;
+  }
+  return ED_operator_screenactive(C);
+}
+
 /* XXX added this to prevent anim state to change during renders */
 static bool ED_operator_screenactive_norender(bContext *C)
 {
@@ -4883,7 +4891,7 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = userpref_show_exec;
-  ot->poll = ED_operator_screenactive;
+  ot->poll = ED_operator_screenactive_nobackground; /* Not in background as this opens a window. */
 }
 
 /** \} */
@@ -4960,7 +4968,7 @@ static void SCREEN_OT_drivers_editor_show(struct wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = drivers_editor_show_exec;
-  ot->poll = ED_operator_screenactive;
+  ot->poll = ED_operator_screenactive_nobackground; /* Not in background as this opens a window. */
 }
 
 /** \} */
@@ -5004,7 +5012,7 @@ static void SCREEN_OT_info_log_show(struct wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = info_log_show_exec;
-  ot->poll = ED_operator_screenactive;
+  ot->poll = ED_operator_screenactive_nobackground;
 }
 
 /** \} */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 6f98ecfd621..9175eb2dbf7 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1911,6 +1911,9 @@ static bool wm_operator_winactive_normal(bContext *C)
   if (!((screen = WM_window_get_active_screen(win)) && (screen->state == SCREENNORMAL))) {
     return 0;
   }
+  if (G.background) {
+    return 0;
+  }
 
   return 1;
 }



More information about the Bf-blender-cvs mailing list