bpy.ops.view3d.view_selected crashes with overridden context #38996

Closed
opened 2014-03-06 16:09:17 +01:00 by Fabian Wickborn · 8 comments

System Information
Windows 7 , Nvidia Quadro 2000

Blender Version
Broken: 2.69.0 (r60995), 2.69 nightly e7f3424 (probably many more, but these were tested by me)

Calling operator bpy.ops.view3d.view_selected from a python script with overriden context crashes Blender.

Exact steps for others to reproduce the error:

  • Start from default Start-Up File
  • Add cube
  • Switch to Scripting window layout
  • Create new text block

Paste the following script and run it by clicking on the Run Script button

  import bpy
  for wm in bpy.data.window_managers:
      for win in wm.windows:
          scene = win.screen.scene
          for area in win.screen.areas:
              if area.type == "VIEW_3D":
                  region = area.spaces[0].region_3d
                  override = bpy.context.copy()
                  override['area'] = area
                  override['region'] = region 
                  bpy.ops.view3d.view_selected(override)
**System Information** Windows 7 , Nvidia Quadro 2000 **Blender Version** Broken: 2.69.0 (r60995), 2.69 nightly e7f3424 (probably many more, but these were tested by me) Calling operator bpy.ops.view3d.view_selected from a python script with overriden context crashes Blender. **Exact steps for others to reproduce the error:** * Open attached .blend file [view_selected_crash.blend](https://archive.blender.org/developer/F80112/view_selected_crash.blend) and run the script in the text editor **or** - Start from default Start-Up File - Add cube - Switch to Scripting window layout - Create new text block # Paste the following script and run it by clicking on the Run Script button ``` import bpy ``` ``` for wm in bpy.data.window_managers: for win in wm.windows: scene = win.screen.scene for area in win.screen.areas: if area.type == "VIEW_3D": region = area.spaces[0].region_3d override = bpy.context.copy() override['area'] = area override['region'] = region bpy.ops.view3d.view_selected(override)

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @fawick

Added subscriber: @fawick
Campbell Barton self-assigned this 2014-03-07 04:22:04 +01:00

Tested in Blender2.70rc1 - and I get this Python script error.

  Traceback (most recent call last):
  File "/d/view_selected_crash.blend/Text", line 12, in <module>
  File "/src/blender/release/scripts/modules/bpy/ops.py", line 186, in __call__
	ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
        RuntimeError: Operator bpy.ops.view3d.view_selected.poll() expected a view3d region
      	Error: Python script fail, look in the console for now...
Tested in Blender2.70rc1 - and I get this Python script error. ``` Traceback (most recent call last): ``` File "/d/view_selected_crash.blend/Text", line 12, in <module> File "/src/blender/release/scripts/modules/bpy/ops.py", line 186, in __call__ ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo) RuntimeError: Operator bpy.ops.view3d.view_selected.poll() expected a view3d region ``` Error: Python script fail, look in the console for now... ```

Did you modify the script to include the call to poll() or is it something that 2.70rc1 did internally?

When I call bpy.ops.view3d.view_selected(override) in the script above, I receive True.

Edit: With 2.69, that is...

Did you modify the script to include the call to poll() or is it something that 2.70rc1 did internally? When I call bpy.ops.view3d.view_selected(override) in the script above, I receive True. Edit: With 2.69, that is...

I downloaded 2.70-RC1 and let the following script run after selecting the cube. It features both poll() as well as calling the operator.

Blender 2.70-RC1 crashes, too.

import bpy
for wm in bpy.data.window_managers:
    for win in wm.windows:
        scene = win.screen.scene
        for area in win.screen.areas:
            if area.type == "VIEW_3D":
                region = area.spaces[0].region_3d
                override = bpy.context.copy()
                override['area'] = area
                override['region'] = region 
                if bpy.ops.view3d.view_selected.poll(override):
                    bpy.ops.view3d.view_selected(override)
                else:
                    print("Inhibited by poll()")

I downloaded 2.70-RC1 and let the following script run after selecting the cube. It features both poll() as well as calling the operator. Blender 2.70-RC1 crashes, too. ``` import bpy ``` ``` for wm in bpy.data.window_managers: for win in wm.windows: scene = win.screen.scene for area in win.screen.areas: if area.type == "VIEW_3D": region = area.spaces[0].region_3d override = bpy.context.copy() override['area'] = area override['region'] = region if bpy.ops.view3d.view_selected.poll(override): bpy.ops.view3d.view_selected(override) else: print("Inhibited by poll()") ```

Added subscriber: @ThomasDinges

Added subscriber: @ThomasDinges

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

This is a type mismatch, area.spaces- [x].region_3d is not a Region type.

Committed type check af84bf2d29

closing.

This is a type mismatch, `area.spaces- [x].region_3d` is not a `Region` type. Committed type check af84bf2d29 closing.
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
3 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#38996
No description provided.