Blender crashes when using an EnumProperty to set Space #100519

Open
opened 2022-08-20 08:15:20 +02:00 by Kevin C. Burke · 8 comments
Contributor

System Information
Operating system: Windows-10-10.0.22000-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94

Blender Version
Broken: version: 3.4.0 Alpha, branch: Timeline-Changes (modified), commit date: 2022-08-05 08:51, hash: 009e1324c9
Worked: (newest version of Blender that worked as expected)

Short description of error
In this script, I'm using context.area.type with a property to change the Space type. It caused Blender to crash.

Exact steps for others to reproduce the error

  1. Running this script from the Text Editor (below)
  2. Switch to Graph Editor or Dope Sheet
  3. Click new property buttons on right of Header
import bpy
from bpy.types import PropertyGroup
from bpy.props import EnumProperty

def set_space(self,value):
    context = bpy.context

    for area in context.screen.areas:
        if area != context.area:
            break

    override = {'region': area.regions[0]}

    if value == 0:
        context.area.type = "GRAPH_EDITOR"
    elif value == 1:
        context.area.type = "DOPESHEET_EDITOR"

class SWITCH_PG_switcher_props(PropertyGroup):
    space: EnumProperty(
        name="Space Target",
        description="Switch to space",
        items=(
            ('GRAPH_EDITOR', "", "Graph Editor", "GRAPH", 0),
            ('DOPESHEET_EDITOR', "", "Dopesheet Editor", "ACTION", 1),
        ),
        default='GRAPH_EDITOR',
        set = set_space
        )

def draw_enum(self, context):
    layout = self.layout
    scene = context.scene
    layout.prop(scene.switcher, "space", icon_only=True, expand=True)

def register():
    bpy.utils.register_class(SWITCH_PG_switcher_props)
    bpy.types.Scene.switcher = bpy.props.PointerProperty(type=SWITCH_PG_switcher_props)
    bpy.types.DOPESHEET_HT_header.append(draw_enum)
    bpy.types.GRAPH_HT_header.append(draw_enum)

def unregister():
    del bpy.types.Scene.switcher
    bpy.types.DOPESHEET_HT_header.remove(draw_enum)
    bpy.types.GRAPH_HT_header.remove(draw_enum)
    bpy.utils.unregister_class(SWITCH_PG_switcher_props)

if __name__ == "__main__":
    register()

Setting the context.area.type in Python seems to cause others' scripts to crash:
Performing a Translate Operation after switching the context area crashes Blender

**System Information** Operating system: Windows-10-10.0.22000-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94 **Blender Version** Broken: version: 3.4.0 Alpha, branch: Timeline-Changes (modified), commit date: 2022-08-05 08:51, hash: `009e1324c9` Worked: (newest version of Blender that worked as expected) **Short description of error** In this script, I'm using `context.area.type` with a property to change the Space type. It caused Blender to crash. **Exact steps for others to reproduce the error** 1. Running this script from the Text Editor (below) 2. Switch to Graph Editor or Dope Sheet 3. Click new property buttons on right of Header ``` import bpy from bpy.types import PropertyGroup from bpy.props import EnumProperty def set_space(self,value): context = bpy.context for area in context.screen.areas: if area != context.area: break override = {'region': area.regions[0]} if value == 0: context.area.type = "GRAPH_EDITOR" elif value == 1: context.area.type = "DOPESHEET_EDITOR" class SWITCH_PG_switcher_props(PropertyGroup): space: EnumProperty( name="Space Target", description="Switch to space", items=( ('GRAPH_EDITOR', "", "Graph Editor", "GRAPH", 0), ('DOPESHEET_EDITOR', "", "Dopesheet Editor", "ACTION", 1), ), default='GRAPH_EDITOR', set = set_space ) def draw_enum(self, context): layout = self.layout scene = context.scene layout.prop(scene.switcher, "space", icon_only=True, expand=True) def register(): bpy.utils.register_class(SWITCH_PG_switcher_props) bpy.types.Scene.switcher = bpy.props.PointerProperty(type=SWITCH_PG_switcher_props) bpy.types.DOPESHEET_HT_header.append(draw_enum) bpy.types.GRAPH_HT_header.append(draw_enum) def unregister(): del bpy.types.Scene.switcher bpy.types.DOPESHEET_HT_header.remove(draw_enum) bpy.types.GRAPH_HT_header.remove(draw_enum) bpy.utils.unregister_class(SWITCH_PG_switcher_props) if __name__ == "__main__": register() ``` Setting the `context.area.type` in Python seems to cause others' scripts to crash: [Performing a Translate Operation after switching the context area crashes Blender ](https://blenderartists.org/t/performing-a-translate-operation-after-switching-the-context-area-crashes-blender/1164763)
Author
Contributor

Added subscriber: @KevinCBurke

Added subscriber: @KevinCBurke

Added subscriber: @1029910278

Added subscriber: @1029910278

It is a bug I think #98514

It is a bug I think #98514

Added subscriber: @rjg

Added subscriber: @rjg

It seems that ui_region_find_active_but provides an invalid pointer when called in ui_region_handler.

It seems that `ui_region_find_active_but` provides an invalid pointer when called in `ui_region_handler`.

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Added subscriber: @ideasman42

Added subscriber: @ideasman42

RNA properties that manipulate the context aren't supported. Looking into the back trace, supporting them would require larger changes to how the UI handles button updates, and these changes don't give provide many benefits besides supporting this particular use-case.

It would be good if the crash could be avoided, so setting as a known-issue.

RNA properties that manipulate the context aren't supported. Looking into the back trace, supporting them would require larger changes to how the UI handles button updates, and these changes don't give provide many benefits besides supporting this particular use-case. It would be good if the crash could be avoided, so setting as a known-issue.
Philipp Oeser removed the
Interest
User Interface
label 2023-02-10 09:21:48 +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
4 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#100519
No description provided.