Many bpy.ops.outliner operators crash running without a region (overridden context) #112618

Closed
opened 2023-09-20 10:50:11 +02:00 by Andrej · 3 comments
Contributor

Blender 3.6.2

Steps to reproduce:

  1. Default Blender scene.
  2. Run the code in the outliner (it will step selection down in outliner)
  3. Uncomment two last lines (same operator but with temp_override). Blender will crash.
import bpy

context = bpy.context

override = {"area": next(area for area in context.screen.areas if area.type == "OUTLINER")}
bpy.ops.outliner.select_walk(override, "INVOKE_DEFAULT", direction="DOWN")

#with context.temp_override(**override):
#    bpy.ops.outliner.select_walk("INVOKE_DEFAULT", direction="DOWN")

Noticed similar case #107805, not completely sure they're really related though.

Blender 3.6.2 Steps to reproduce: 1. Default Blender scene. 2. Run the code in the outliner (it will step selection down in outliner) 3. Uncomment two last lines (same operator but with `temp_override`). Blender will crash. ```python import bpy context = bpy.context override = {"area": next(area for area in context.screen.areas if area.type == "OUTLINER")} bpy.ops.outliner.select_walk(override, "INVOKE_DEFAULT", direction="DOWN") #with context.temp_override(**override): # bpy.ops.outliner.select_walk("INVOKE_DEFAULT", direction="DOWN") ``` Noticed similar case #107805, not completely sure they're really related though.
Andrej added the
Severity
Normal
Type
Report
Status
Needs Triage
labels 2023-09-20 10:50:11 +02:00

I can confirm.
In this case, the crash happens because context.region is None when changing the area.
In fact, it is similar to #107805: Wrong context override crashes Blender

I can confirm. In this case, the crash happens because `context.region` is `None` when changing the area. In fact, it is similar to #107805: Wrong context override crashes Blender
Germano Cavalcante added
Module
Python API
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-09-21 03:40:45 +02:00
Member

You could of course specify the region in the override as well, something like the following does not crash:

for window in context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
        if area.type == 'OUTLINER':
            for region in area.regions:
                if region.type == 'WINDOW':
                    override = {'window': window, 'screen': screen,
                            'area': area, 'region': region}

But avoiding the crashes would still be nice (in the style of 72688791dc and/or a8892c7264), will put on my desk

You could of course specify the region in the override as well, something like the following does not crash: ``` for window in context.window_manager.windows: screen = window.screen for area in screen.areas: if area.type == 'OUTLINER': for region in area.regions: if region.type == 'WINDOW': override = {'window': window, 'screen': screen, 'area': area, 'region': region} ``` But avoiding the crashes would still be nice (in the style of 72688791dcb2b62f6e7ce2f53d26e8d8e2f2f215 and/or a8892c7264356e32567e706e78539121b8f42ce0), will put on my desk
Philipp Oeser self-assigned this 2024-03-20 10:30:40 +01:00
Member

I went over all Outliner operators and the following are crashing without a region (or are otherwise affected):

invoke and exec

  • OUTLINER_OT_select_box
  • OUTLINER_OT_id_remap

only invoke

  • OUTLINER_OT_item_activate
  • OUTLINER_OT_operation
  • OUTLINER_OT_highlight_update (not a problem, checks mouse outside area prior)
  • OUTLINER_OT_item_rename
  • OUTLINER_OT_id_delete
  • OUTLINER_OT_lib_relocate
  • OUTLINER_OT_parent_drop
  • OUTLINER_OT_scene_drop
  • OUTLINER_OT_material_drop
  • OUTLINER_OT_lib_reload (not registered, but still...)

invoke and modal

  • OUTLINER_OT_item_openclose

only exec

  • OUTLINER_OT_show_active
  • OUTLINER_OT_scroll_page
  • OUTLINER_OT_collection_new

no crashes, but not updating properly due to missing region):

  • OUTLINER_OT_show_one_level
  • OUTLINER_OT_show_active
  • OUTLINER_OT_show_hierarchy
  • OUTLINER_OT_expanded_toggle

having dedicated polls that prevent crashes for missing regions

  • OUTLINER_OT_data_operation
  • OUTLINER_OT_keyingset_add_selected
  • OUTLINER_OT_keyingset_remove_selected
  • OUTLINER_OT_drivers_add_selected
  • OUTLINER_OT_drivers_delete_selected
I went over all Outliner operators and the following are crashing without a region (or are otherwise affected): invoke and exec - OUTLINER_OT_select_box - OUTLINER_OT_id_remap only invoke - OUTLINER_OT_item_activate - OUTLINER_OT_operation - OUTLINER_OT_highlight_update (not a problem, checks mouse outside area prior) - OUTLINER_OT_item_rename - OUTLINER_OT_id_delete - OUTLINER_OT_lib_relocate - OUTLINER_OT_parent_drop - OUTLINER_OT_scene_drop - OUTLINER_OT_material_drop - OUTLINER_OT_lib_reload (not registered, but still...) invoke and modal - OUTLINER_OT_item_openclose only exec - OUTLINER_OT_show_active - OUTLINER_OT_scroll_page - OUTLINER_OT_collection_new no crashes, but not updating properly due to missing region): - OUTLINER_OT_show_one_level - OUTLINER_OT_show_active - OUTLINER_OT_show_hierarchy - OUTLINER_OT_expanded_toggle having dedicated polls that prevent crashes for missing regions - OUTLINER_OT_data_operation - OUTLINER_OT_keyingset_add_selected - OUTLINER_OT_keyingset_remove_selected - OUTLINER_OT_drivers_add_selected - OUTLINER_OT_drivers_delete_selected
Philipp Oeser changed title from bpy.ops.outliner.select_walk + INVOKE_DEFAULT + temp_override crashes Blender to Many bpy.ops.outliner operators crash running without a region (overridden context) 2024-03-20 13:15:03 +01:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-03-26 09:31:05 +01:00
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blender/blender#112618
No description provided.