[Bf-blender-cvs] [79d4740edab] blender-v3.2-release: Cleanup: use context.temp_override

Campbell Barton noreply at git.blender.org
Tue May 3 01:34:00 CEST 2022


Commit: 79d4740edabbe0a7cd20b708a4c67e69958396b4
Author: Campbell Barton
Date:   Tue May 3 09:32:28 2022 +1000
Branches: blender-v3.2-release
https://developer.blender.org/rB79d4740edabbe0a7cd20b708a4c67e69958396b4

Cleanup: use context.temp_override

Remove use of deprecated operator context passing.

Also minor clarification in the context.temp_override docs.

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

M	doc/python_api/examples/bpy.types.Context.temp_override.1.py
M	release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py

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

diff --git a/doc/python_api/examples/bpy.types.Context.temp_override.1.py b/doc/python_api/examples/bpy.types.Context.temp_override.1.py
index 68f0eef93c3..6213db30e00 100644
--- a/doc/python_api/examples/bpy.types.Context.temp_override.1.py
+++ b/doc/python_api/examples/bpy.types.Context.temp_override.1.py
@@ -10,7 +10,7 @@ Notes:
 
 - Temporary context overrides may be nested, when this is done, members will be added to the existing overrides.
 
-- Context members are restored outside the scope of the context.
+- Context members are restored outside the scope of the context-manager.
   The only exception to this is when the data is no longer available.
 
   In the event windowing data was removed (for example), the state of the context is left as-is.
diff --git a/release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py b/release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py
index 0f5b81041cf..cdf7d0bad5c 100644
--- a/release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py
+++ b/release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py
@@ -14,6 +14,8 @@ def update_factory_startup_screens():
 
 
 def update_factory_startup_ffmpeg_preset():
+    from bpy import context
+
     preset = "H264_in_MP4"
     preset_filepath = bpy.utils.preset_find(preset, preset_path="ffmpeg")
     if not preset_filepath:
@@ -24,7 +26,8 @@ def update_factory_startup_ffmpeg_preset():
         render.image_settings.file_format = 'FFMPEG'
 
         if preset_filepath:
-            bpy.ops.script.python_file_run({"scene": scene}, filepath=preset_filepath)
+            with context.temp_override(scene=scene):
+                bpy.ops.script.python_file_run(filepath=preset_filepath)
 
         render.ffmpeg.audio_codec = 'AAC'
         render.ffmpeg.audio_bitrate = 256



More information about the Bf-blender-cvs mailing list