temp_override with bpy.ops.screen.area_close() affects the bpy.context permanently #114509

Open
opened 2023-11-05 22:49:02 +01:00 by Gixo · 1 comment

System Information
Operating system: Linux-6.5.9-zen2-1-zen-x86_64-with-glibc2.38 64 Bits, WAYLAND UI
Graphics card: NVIDIA GeForce GTX 1660 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 545.29.02

Blender Version
Broken: version: 4.0.0 Beta, branch: blender-v4.0-release, commit date: 2023-11-01 18:27, hash: 0b81a163e256
Worked: 3.6.5

Short description of error
When using the bpy.ops.screen.area_close() with temp_override it changes the context.screen/window/etc. to None.

Exact steps for others to reproduce the error

When using the bpy.ops.screen.area_close() with temp_override, it is expected that the current context is kept as is, but it turns context.screen or context.window to None like it would without running it with temp_override.

Running the code below in Blender 3.6 vs 4.0 should demonstrate the problem:

import bpy

print(f"First check: {bpy.context.screen}")
area = bpy.context.screen.areas[-1]
with bpy.context.temp_override(area=area):
    bpy.ops.screen.area_close()
print(f"Second check: {bpy.context.screen}")

The sample output on 3.6:

First check: <bpy_struct, Screen("Scripting") at 0x7fc5d1f28108>
Second check: <bpy_struct, Screen("Scripting") at 0x7fc5d1f28108>

The sample output on 4.0:

First check: <bpy_struct, Screen("Scripting") at 0x7f50200c3188>
Second check: None
**System Information** Operating system: Linux-6.5.9-zen2-1-zen-x86_64-with-glibc2.38 64 Bits, WAYLAND UI Graphics card: NVIDIA GeForce GTX 1660 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 545.29.02 **Blender Version** Broken: version: 4.0.0 Beta, branch: blender-v4.0-release, commit date: 2023-11-01 18:27, hash: `0b81a163e256` Worked: 3.6.5 **Short description of error** When using the `bpy.ops.screen.area_close()` with temp_override it changes the `context.screen/window/etc.` to `None`. **Exact steps for others to reproduce the error** When using the `bpy.ops.screen.area_close()` with temp_override, it is expected that the current context is kept as is, but it turns `context.screen` or `context.window` to None like it would without running it with temp_override. Running the code below in Blender 3.6 vs 4.0 should demonstrate the problem: ```python import bpy print(f"First check: {bpy.context.screen}") area = bpy.context.screen.areas[-1] with bpy.context.temp_override(area=area): bpy.ops.screen.area_close() print(f"Second check: {bpy.context.screen}") ``` The sample output on 3.6: ```shell First check: <bpy_struct, Screen("Scripting") at 0x7fc5d1f28108> Second check: <bpy_struct, Screen("Scripting") at 0x7fc5d1f28108> ``` The sample output on 4.0: ```shell First check: <bpy_struct, Screen("Scripting") at 0x7f50200c3188> Second check: None ```
Gixo added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-11-05 22:49:03 +01:00
Gixo changed title from temp_override with bpy.ops.screen.area_close() effects the bpy.context permanently to temp_override with bpy.ops.screen.area_close() affects the bpy.context permanently 2023-11-05 22:49:17 +01:00

The behavior changed in 0df7d100a3 (@ideasman42).

But once the window is set to None, it is expected that the screen will be None as well.

The window is set to None because of was described in the comment of 9290b41381 (@Harley):

 /* Ensure the event loop doesn't attempt to continue handling events.
   *
   * This causes execution from the Python console fail to return to the prompt as it should.
   * This glitch could be solved in the event loop handling as other operators may also
   * destructively manipulate windowing data. */

Maybe it's a limitation. But confirming for now.

The behavior changed in 0df7d100a3 (@ideasman42). But once the window is set to `None`, it is expected that the screen will be `None` as well. The window is set to `None` because of was described in the comment of 9290b41381 (@Harley): ``` /* Ensure the event loop doesn't attempt to continue handling events. * * This causes execution from the Python console fail to return to the prompt as it should. * This glitch could be solved in the event loop handling as other operators may also * destructively manipulate windowing data. */ ``` Maybe it's a limitation. But confirming for now.
Campbell Barton self-assigned this 2023-11-07 09:45:36 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#114509
No description provided.