'prop_search' function appears broken in 2.8 #59106

Closed
opened 2018-12-10 06:31:32 +01:00 by Christopher Gearhart · 11 comments

System Information
Operating system: Mac OS X
Graphics card: Radeon Pro 560X 4096 MB

Blender Version
Broken: blender2.8
Worked: 2.79c release

Short description of error

The prop_search function has been giving me issues in 2.8 when I incorporate it into my add-ons.

When I select something from the prop_search dropdown list in Blender, the value stored to the target property includes three spaces of padding at the beginning (along with the '0' indicating the data block has no users if it appears in the dropdown), as if the dropdown list formatting is transferred with the name of the data block.

I'm guessing this is just an indexing error, where the entire string is stored to the target property instead of the fourth character on (e.g. in python: datablock_string- [x] should be datablock_string[3:])

Exact steps for others to reproduce the error

  • From the default startup, run the following script:
import bpy
from bpy.props import *
from bpy.types import Scene, Panel

class TESTER_PT_test(Panel):
    bl_space_type  = "VIEW_3D"
    bl_region_type = "UI"
    bl_label       = "Test Panel"
    bl_idname      = "BRICKER_PT_detailing"
    bl_context     = "objectmode"
    bl_category    = "Test Addon"
    
    def draw(self, context):
        layout = self.layout
        scn = bpy.context.scene
        col = layout.column(align=True)
        col.prop_search(scn, "target_object_test", bpy.data, "objects", text='')

def register():
    bpy.utils.register_class(TESTER_PT_test)
    Scene.target_object_test = StringProperty(default="")

def unregister():
    del Scene.target_object_test
    bpy.utils.unregister_class(TESTER_PT_test)
    
register()
  • Open the right-hand sidebar in the viewport if not already open (in default keymap, press n).
  • Open the 'Test Addon' tab in the right-hand sidebar
  • Select an object from the property search in the 'Test Panel'
  • Open a new UI window and select the 'Info' editor type
  • Note that bpy.context.scene.target_object_test has been set to the correct object name, but has also been padded with three spaces in front
**System Information** Operating system: Mac OS X Graphics card: Radeon Pro 560X 4096 MB **Blender Version** Broken: blender2.8 Worked: 2.79c release **Short description of error** The `prop_search` function has been giving me issues in 2.8 when I incorporate it into my add-ons. When I select something from the `prop_search` dropdown list in Blender, the value stored to the target property includes three spaces of padding at the beginning (along with the '0' indicating the data block has no users if it appears in the dropdown), as if the dropdown list formatting is transferred with the name of the data block. I'm guessing this is just an indexing error, where the entire string is stored to the target property instead of the fourth character on (e.g. in python: datablock_string- [x] should be datablock_string[3:]) **Exact steps for others to reproduce the error** - From the default startup, run the following script: ``` import bpy from bpy.props import * from bpy.types import Scene, Panel class TESTER_PT_test(Panel): bl_space_type = "VIEW_3D" bl_region_type = "UI" bl_label = "Test Panel" bl_idname = "BRICKER_PT_detailing" bl_context = "objectmode" bl_category = "Test Addon" def draw(self, context): layout = self.layout scn = bpy.context.scene col = layout.column(align=True) col.prop_search(scn, "target_object_test", bpy.data, "objects", text='') def register(): bpy.utils.register_class(TESTER_PT_test) Scene.target_object_test = StringProperty(default="") def unregister(): del Scene.target_object_test bpy.utils.unregister_class(TESTER_PT_test) register() ``` - Open the right-hand sidebar in the viewport if not already open (in default keymap, press `n`). - Open the 'Test Addon' tab in the right-hand sidebar - Select an object from the property search in the 'Test Panel' - Open a new UI window and select the 'Info' editor type - Note that `bpy.context.scene.target_object_test` has been set to the correct object name, but has also been padded with three spaces in front

Added subscriber: @bblanimation

Added subscriber: @bblanimation

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Campbell Barton self-assigned this 2018-12-10 07:19:44 +01:00
Scene no longer has 'objects', see: https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Scene_and_Object_API

Changed status from 'Archived' to: 'Open'

Changed status from 'Archived' to: 'Open'

Thank you for pointing this out – I've updated the sample script to reflect this. The issue still remains as described.

Thank you for pointing this out – I've updated the sample script to reflect this. The issue still remains as described.

Added subscriber: @mont29

Added subscriber: @mont29

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

There is no bug here, rather some limitation with current UI code for property search, we cannot decouple UI text from what is stored in string property currently. And for IDs, we want to show a complete UI text, with those two-chars prefix, and the library suffix if needed.

The root of the issue is actually that you are using a text property to store search result on an ID collection. Those should be stored in pointer properties, unless there is a very good reason not to.

There is no bug here, rather some limitation with current UI code for property search, we cannot decouple UI text from what is stored in string property currently. And for IDs, we want to show a complete UI text, with those two-chars prefix, and the library suffix if needed. The root of the issue is actually that you are using a text property to store search result on an ID collection. Those should be stored in pointer properties, unless there is a very good reason not to.

Added subscriber: @RomboutVersluijs

Added subscriber: @RomboutVersluijs

in 2.8 branch when i try to add a template_list using PointerProperty, its returns an error that it needs a CollectionProperty. The issue i see with this is that the filer operator does not work now?

Below are snippets from the Rokoko addon. It uses template_list, it shows a list with left source bone names and right target bones names which can be picked using a prop_search.

Scene.rsl_retargeting_bone_list = CollectionProperty(
        type=retargeting_ui.BoneListItem
    )
row.template_list("RSL_UL_BoneList", "Bone List", context.scene, "rsl_retargeting_bone_list", context.scene, "rsl_retargeting_bone_list_index", rows=1, maxrows=10)

class BoneListItem(PropertyGroup):
    """Properties of the bone list items"""
    bone_name_source: StringProperty(
        name="Source Bone",
        description="The source bone name",
        default="Undefined")

    bone_name_target: StringProperty(
        name="Target Bone",
        description="The target bone name",
        default="")

    bone_name_key: StringProperty(
        name="Auto Detection Key",
        description="The automatically detected bone key",
        default="")


class RSL_UL_BoneList(UIList):
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        armature_target = get_target_armature()

        layout = layout.split(factor=0.36, align=True)
        layout.label(text=item.bone_name_source)
        if armature_target:
            layout.prop_search(item, 'bone_name_target', armature_target.pose, "bones", text='')
            # layout.label(text=item.bone_name_target)

in 2.8 branch when i try to add a template_list using PointerProperty, its returns an error that it needs a CollectionProperty. The issue i see with this is that the filer operator does not work now? Below are snippets from the Rokoko addon. It uses template_list, it shows a list with left source bone names and right target bones names which can be picked using a prop_search. ``` Scene.rsl_retargeting_bone_list = CollectionProperty( type=retargeting_ui.BoneListItem ) row.template_list("RSL_UL_BoneList", "Bone List", context.scene, "rsl_retargeting_bone_list", context.scene, "rsl_retargeting_bone_list_index", rows=1, maxrows=10) class BoneListItem(PropertyGroup): """Properties of the bone list items""" bone_name_source: StringProperty( name="Source Bone", description="The source bone name", default="Undefined") bone_name_target: StringProperty( name="Target Bone", description="The target bone name", default="") bone_name_key: StringProperty( name="Auto Detection Key", description="The automatically detected bone key", default="") class RSL_UL_BoneList(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): armature_target = get_target_armature() layout = layout.split(factor=0.36, align=True) layout.label(text=item.bone_name_source) if armature_target: layout.prop_search(item, 'bone_name_target', armature_target.pose, "bones", text='') # layout.label(text=item.bone_name_target) ```
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
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#59106
No description provided.