Page MenuHome

Assert when using prop_tabs_enum
Closed, ResolvedPublicBUG


System Information
Operating system: Linux-5.4.0-40-generic-x86_64-with-debian-bullseye-sid 64 Bits
Graphics card: GeForce GTX 760/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21

Blender Version
Broken: version: 2.90.0 Alpha, branch: master, commit date: 2020-07-03 10:56, hash: rBaab41401f9e9

Short description of error
Using prop_tabs_enum in an add-on results in an assert being triggered in ui_block_align_but_to_region (interface_align.c). This happens because ui_but_align_opposite_to_area_align_get returns zero when called in template_ID_tabs (interface_templates.c) for this UI element.

rBce148716c8163162ba7275980792d432c0b3f5ed introduced the prop_tabs_enum function with the described behavior.

Exact steps for others to reproduce the error

  1. Open the text editor
  2. Run the following script
  3. Open the scene properties
bl_info = {
    "name": "MWE T78575",
    "author": "Robert Guetzkow",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "Scene properties > Example tab",
    "description": "Minimum working example for T78575",
    "warning": "",
    "wiki_url": "",
    "category": "3D View"}

import bpy

class ExampleProperties(bpy.types.PropertyGroup):
    enum: bpy.props.EnumProperty(items=[("id_0", "First", "Description of first entry", 0),
                                        ("id_1", "Second", "Description of second entry", 1),
                                        ("id_2", "Third", "Description of third entry", 2)],

class EXAMPLE_PT_panel(bpy.types.Panel):
    bl_label = "Example Panel"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        layout.prop_tabs_enum(context.scene.mwe_t78575, "enum")

classes = (ExampleProperties, EXAMPLE_PT_panel)

def register():
    for cls in classes:
    bpy.types.Scene.mwe_t78575 = bpy.props.PointerProperty(type=ExampleProperties)

def unregister():
    for cls in classes:
    del bpy.types.Scene.mwe_t78575

Event Timeline

I cannot reproduce.
blender-2.90.0- 5a13f682ee5f -linux64

I can't reproduce this with the same commit nor with the current master. For this error to occur, you would have to have an uiBut that doesn't fit in any of the alignment categories that are listed in ui_block_align_but_to_region.

Strange. It's a straight debug build of master without any patches. I'll check if there's an addon causing this, I though I disabled them all, but maybe I overlooked one.

An add-on should't cause asserts I think? So then it would still be a bug?

That's it. The assert is caused by this add-on

Which I forgot to disable.

Does this still count as a bug or is this considered a bug in the add-on?

@Martijn Versteegh (Baardaap) I'll take a look. It depends on whether the Python API is used correctly.

Robert Guetzkow (rjg) added a comment.EditedJul 3 2020, 6:14 PM

@Martijn Versteegh (Baardaap) Which version of the add-on are you using? There are two branches for 2.8 and a devel branch.

I have 30d2682 from the blender-2.80 branch

This appear to be a bug in the add-on. Parts of the unfinished UI code has been disabled in commit ab9dfff41f7cb333c707f41052fc0c2c15ead9f5.

The source of the issue appears to be layout.prop_tabs_enum(props, "perspective"). This appears to be a bug.

The API change was introduced in rBce148716c8163162ba7275980792d432c0b3f5ed which also added ui_but_align_opposite_to_area_align_get and modified template_ID_tabs (interface_templates.c). Previously the alignment was assigned as:

const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP;

After the change it is:

const int but_align = ui_but_align_opposite_to_area_align_get(region);

ui_but_align_opposite_to_area_align_get may return zero, which happens in this case and results in the assert being triggered in ui_block_align_but_to_region (interface_align.c)

Robert Guetzkow (rjg) renamed this task from BLI_Assert(0) when deleting anything from the outliner. to Assert when using prop_tabs_enum.Jul 4 2020, 2:02 PM
Robert Guetzkow (rjg) changed the task status from Needs Triage to Confirmed.
Robert Guetzkow (rjg) updated the task description. (Show Details)
Robert Guetzkow (rjg) updated the task description. (Show Details)

@Julian Eisel (Severin) This might be for you, since you've originally implemented this feature.

Julian Eisel (Severin) changed the subtype of this task from "Report" to "Bug".