Maniphest T50426

Enum Property names are not displayed correctly
Closed, Archived

Assigned To
Bastien Montagne (mont29)
Authored By
Andreas Esau (ndee)
Jan 14 2017, 10:35 AM
Tags
  • BF Blender
  • Add-ons (BF-Blender)
Subscribers
Andrea Donati (Andreax81)
Andreas Esau (ndee)

Description

System Information
Operating system and graphics card

Blender Version
Broken: (example: 2.78a e8299c8)

Short description of error
I have created a custom EnumProperty which uses a function to generate a dynamic list of items. That function loops over all brushes and creates a list out of them.
Displaying that enum property via layout.template_icon_view(context.scene, "prop_name",show_labels=True) and layout.prop(context.scene, "prop_name",expand=True) is resulting in totally messed up names.
Items are displaying names of other items or crypted text.

For template_icon_view it sometimes works properly, but most of the time not.

However, displaying the property via layout.prop(context.scene, "prop_name",expand=True) works perfectly fine. Always.

Exact steps for others to reproduce the error
I have attached a blendfile showcasing the problem and also a small video.

Related Objects

Mentioned In
T56435: EnumProperty displays wrong labels when using expand=True
Mentioned Here
rBe8299c81006a: Cycles: Don't use guarded vector for statically initialized data

Event Timeline

Andreas Esau (ndee) created this task.Jan 14 2017, 10:35 AM
Andreas Esau (ndee) added a comment.Jan 14 2017, 10:39 AM

If the attached video is not displaying correctly.
Here is a link to it:
https://www.dropbox.com/s/bykn28wf4nikht1/blender_enum_flicker_02.mp4?dl=0

Brendon Murphy (meta-androcto) assigned this task to Bastien Montagne (mont29).Jan 14 2017, 10:51 AM
Bastien Montagne (mont29) changed the task status from Unknown Status to Archived.Jan 14 2017, 11:00 AM

Thanks for the report, but that’s more a known issue than a bug here, as stated by the API documentation, you have to keep a (python local) reference to the strings you return in that items callback, something like this shall work:

BRUSHES = []
def get_brushes(self,context):
    global BRUSHES
    BRUSHES = []
    for i,brush in enumerate(bpy.data.brushes):
        icon_id = bpy.types.UILayout.icon(brush)
        name = "%s" % brush.name
        BRUSHES.append((name, name, name, icon_id, i))
    return BRUSHES
Andreas Esau (ndee) added a comment.Jan 14 2017, 11:20 AM

Ok thanks for the quick answer @Bastien Montagne (mont29)
The global keyword disables the flickering but names could still be mixed up. Some brushes are named twice with the same label.. this is somehow weird.

Andrea Donati (Andreax81) added a subscriber: Andrea Donati (Andreax81).Jan 30 2020, 1:32 AM
This comment was removed by Andrea Donati (Andreax81).