Unicode strings in ID properties cause UI glitch #48992

Closed
opened 2016-08-01 15:30:23 +02:00 by Sybren A. Stüvel · 5 comments

System Information
Kubuntu 16.04

Blender Version
Broken: 2.70a, 2.77a and 7065022f7a (2.65a also fails, but just shows an empty value)
Worked: 2.60a

Short description of error
When an EnumProperty gets its values from a function, which uses an Unicode string from an ID property, the UI gets corrupted.

blender-id-prop-bug.png

Exact steps for others to reproduce the error

  1. Grab this blend file bugreport.blend
  2. Ensure the default cube is still selected, and run the script
  3. Scroll down the object properties panel, and open the "String bug panel"
  4. Move your mouse to trigger UI updates, and see the value flicker between different invalid strings.

This is the code from the blend file that triggers this error:

import bpy

# Run this script with the default cube selected.
bpy.context.object['id_value'] = '½k'

def get_items(self, context):
    - These values are the same in Python, but are handled differently
    - by Blender.

assert self['id_value'] == '½k'

return [
('buggy_key', self['id_value'], 'This value is very buggy in the GUI'),
('okay_key', '½k', 'This value is just fine'),
]


bpy.types.Object.buggy_prop = bpy.props.EnumProperty(

items=get_items)



class StringBugPanel(bpy.types.Panel):

bl_label = "String bug panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"


def draw(self, context):
self.layout.prop(context.object, "buggy_prop")



def register():

bpy.utils.register_class(StringBugPanel)



def unregister():

bpy.utils.unregister_class(StringBugPanel)



if __name__ == "__main__":

register()

As you can see, the bug doesn't manifest itself when the string is a pure Python string (the 'okay_key' value). However, it fails if it is stored in an ID property, even though the two are considered equal in the Python domain.

Update: I've tested to create a copy of the string, using self['id_value']- [x] and str(self['id_value']), but that also gets corrupted. Concatenating with 'xx' + self['id_value'] also gets corrupted.

**System Information** Kubuntu 16.04 **Blender Version** Broken: 2.70a, 2.77a and 7065022f7aa (2.65a also fails, but just shows an empty value) Worked: 2.60a **Short description of error** When an `EnumProperty` gets its values from a function, which uses an Unicode string from an ID property, the UI gets corrupted. ![blender-id-prop-bug.png](https://archive.blender.org/developer/F330928/blender-id-prop-bug.png) **Exact steps for others to reproduce the error** 1. Grab this blend file [bugreport.blend](https://archive.blender.org/developer/F330930/bugreport.blend) 2. Ensure the default cube is still selected, and run the script 3. Scroll down the object properties panel, and open the "String bug panel" 4. Move your mouse to trigger UI updates, and see the value flicker between different invalid strings. This is the code from the blend file that triggers this error: ```lang=python import bpy # Run this script with the default cube selected. bpy.context.object['id_value'] = '½k' def get_items(self, context): - These values are the same in Python, but are handled differently - by Blender. ``` assert self['id_value'] == '½k' return [ ('buggy_key', self['id_value'], 'This value is very buggy in the GUI'), ('okay_key', '½k', 'This value is just fine'), ] ``` bpy.types.Object.buggy_prop = bpy.props.EnumProperty( ``` items=get_items) ``` class StringBugPanel(bpy.types.Panel): ``` bl_label = "String bug panel" bl_idname = "OBJECT_PT_hello" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "object" ``` ``` def draw(self, context): self.layout.prop(context.object, "buggy_prop") ``` def register(): ``` bpy.utils.register_class(StringBugPanel) ``` def unregister(): ``` bpy.utils.unregister_class(StringBugPanel) ``` if __name__ == "__main__": ``` register() ``` ``` As you can see, the bug doesn't manifest itself when the string is a pure Python string (the 'okay_key' value). However, it fails if it is stored in an ID property, even though the two are considered equal in the Python domain. **Update:** I've tested to create a copy of the string, using `self['id_value']- [x]` and `str(self['id_value'])`, but that also gets corrupted. Concatenating with `'xx' + self['id_value']` also gets corrupted.
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Added subscriber: @brecht

Added subscriber: @brecht

I suspect it's the same as issue as blender/blender-addons#48873.

I suspect it's the same as issue as blender/blender-addons#48873.

Closed as duplicate of blender/blender-addons#48873

Closed as duplicate of blender/blender-addons#48873
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
2 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#48992
No description provided.