bpy.data.* name lookups are no longer reliable #61998

Closed
opened 2019-02-27 01:32:54 +01:00 by Campbell Barton · 11 comments

The following script asserts on the last line when it shouldn't, caused by 456e3f00e0

  import bpy
  a = bpy.data.meshes.new("A")
  b = bpy.data.meshes.new(" F A")
  a.use_fake_user = True
  bpy.data.meshes.remove(b)
  b = bpy.data.meshes.get(" F A")
  assert(b is None)
The following script asserts on the last line when it shouldn't, caused by 456e3f00e0 ``` import bpy a = bpy.data.meshes.new("A") b = bpy.data.meshes.new(" F A") a.use_fake_user = True bpy.data.meshes.remove(b) b = bpy.data.meshes.get(" F A") assert(b is None)
Author
Owner

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Added subscriber: @mont29

Added subscriber: @mont29

Yes, currently this will break. If people find it fancy to use names like F Blabla for their IDs, sorry but I’d consider this very odd corner case that should not happen in real life. Much more unlikely than having a Blabla local object together with a Blabla linked one, and not being able to distinguish them in the UI ID selectors (as was the case before). You can also use completely broken meshes with booleans and claim they are not working. Or you can name your bone Foo.R and the next one Foo.L, enable mirror edit, and say that it breaks your armature. etc. etc.

Now, background for that behavior: UI widget (ID pointer drop-down selector) uses UI string to also lookup for the ID. So you can either cope with that on the generic ID lookup system, or you can go into that nightmarish UI code to make it properly separate ID identifier from UI name, store both, and return proper full qualified ID identifier instead of UI name as its value… If you feel like doing that, be my guest.

Yes, currently this will break. If people find it fancy to use names like ` F Blabla` for their IDs, sorry but I’d consider this very odd corner case that should not happen in real life. Much more unlikely than having a `Blabla` local object together with a `Blabla` linked one, and not being able to distinguish them in the UI ID selectors (as was the case before). You can also use completely broken meshes with booleans and claim they are not working. Or you can name your bone `Foo.R` and the next one `Foo.L`, enable mirror edit, and say that it breaks your armature. etc. etc. Now, background for that behavior: UI widget (ID pointer drop-down selector) uses UI string to also lookup for the ID. So you can either cope with that on the generic ID lookup system, or you can go into that nightmarish UI code to make it properly separate ID identifier from UI name, store both, and return proper full qualified ID identifier instead of UI name as its value… If you feel like doing that, be my guest.
Author
Owner

Sure, there are areas in Blender which are in a bad state, but this isn't reason to add more. We managed for years without this kind of hack.

Really this isn't acceptable - name look-ups must be fast and accurate, the UI must work around this. Would consider having a separate UI identifier less hackish/error prone.

Sure, there are areas in Blender which are in a bad state, but this isn't reason to add more. We managed for years without this kind of hack. Really this isn't acceptable - name look-ups must be fast and accurate, the UI must work around this. Would consider having a separate UI identifier less hackish/error prone.
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Related discussion: blender/blender-addons#58641

Related discussion: blender/blender-addons#58641

Added subscriber: @brecht

Added subscriber: @brecht
Bastien Montagne was assigned by Brecht Van Lommel 2019-02-27 14:38:12 +01:00

Please revert 4669c3692c and 456e3f00e0, and then we can add a better implementation after that.

Issues like blender/blender-addons#58641, #58917 are not at all obvious for Python API users or even Blender developers, this will likely cause more bugs in the future.

Please revert 4669c3692c and 456e3f00e0, and then we can add a better implementation after that. Issues like blender/blender-addons#58641, #58917 are not at all obvious for Python API users or even Blender developers, this will likely cause more bugs in the future.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Removed subscriber: @mont29

Removed subscriber: @mont29
Bastien Montagne removed their assignment 2019-02-27 16:45:12 +01:00

Reverted. People who like UI code can go fixing that mess the proper way if they want.

Reverted. People who like UI code can go fixing that mess the proper way if they want.
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
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#61998
No description provided.