Inconsistancy renaming datablock behaviour #115192

Closed
opened 2023-11-20 15:59:22 +01:00 by Julien Duroure · 9 comments
Member

System Information
Operating system: Mint
Graphics card: Nvidia

Blender Version
Broken: 4.1 alpha f815484e7d
Worked: ?

When renaming datablock, and the name already exists

  • Some datablock renamed with .001 the datablock.
  • Some others, sometimes, renamed all other datablock with suffixes, to let you choose the name with any suffixes.

This last case is bad/dangerous imho, as we are silently renaming some data without let it know to the user.
Here is how to reproduce (seems order of renaming and name choose are important):

  1. On default scene, duplicate the cube.
  2. The new cube is now selected, rename (in Property panel) to "Hello".
  3. Select the initial cube, rename to "Hello".
  4. No issue here, the cube renamed automatically to "Hello.001".
  5. Still on initial cube you just renamed, rename it "Coucou".
  6. Select the other cube, and rename "Coucou".
  7. It does not renamed to "Coucou.001".
  8. But select the other one, and it renamed silently to "Coucou.001".

See video attached.

Same happen with images, using bpy (detected in a glTF import process)

Edit: For images, run the following code (but be sure to link to existing image path, not provided here)

import bpy
blender_image1 = bpy.data.images.load('/tmp/test.png', check_existing=True)
blender_image1.name = "Image"
blender_image2 = bpy.data.images.load('/tmp/test2.png', check_existing=True)
blender_image2.name = "Image"

**System Information** Operating system: Mint Graphics card: Nvidia **Blender Version** Broken: 4.1 alpha f815484e7d45 Worked: ? When renaming datablock, and the name already exists - Some datablock renamed with .001 the datablock. - Some others, sometimes, renamed all other datablock with suffixes, to let you choose the name with any suffixes. This last case is bad/dangerous imho, as we are silently renaming some data without let it know to the user. Here is how to reproduce (seems order of renaming and name choose are important): 1. On default scene, duplicate the cube. 2. The new cube is now selected, rename (in Property panel) to "Hello". 3. Select the initial cube, rename to "Hello". 4. No issue here, the cube renamed automatically to "Hello.001". 5. Still on initial cube you just renamed, rename it "Coucou". 6. Select the other cube, and rename "Coucou". 7. It does not renamed to "Coucou.001". 8. But select the other one, and it renamed silently to "Coucou.001". See video attached. Same happen with images, using bpy (detected in a glTF import process) Edit: For images, run the following code (but be sure to link to existing image path, not provided here) > import bpy blender_image1 = bpy.data.images.load('/tmp/test.png', check_existing=True) blender_image1.name = "Image" blender_image2 = bpy.data.images.load('/tmp/test2.png', check_existing=True) blender_image2.name = "Image"
Julien Duroure added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-11-20 15:59:23 +01:00

Not sure is i can confirm this.

Not sure is i can confirm this.
Iliya Katushenock added the
Interest
User Interface
label 2023-11-20 16:05:06 +01:00

I don't kow but may be connection to "Hello World!" because just Hello and World :D renamed like that...

I don't kow but may be connection to "Hello World!" because just Hello and World :D renamed like that...
Author
Member

I edited the description to add a case with bpy and image creation

I edited the description to add a case with bpy and image creation
Member

Hi, yes, can confirm even in previous releases. I'll add this to my list for investigating during weekend.

Hi, yes, can confirm even in previous releases. I'll add this to my list for investigating during weekend.
Pratik Borhade self-assigned this 2023-11-21 11:49:52 +01:00
Author
Member

@PratikPB2123 Any news? Did you get time to investigate?

@PratikPB2123 Any news? Did you get time to investigate?
Member

Sorry @JulienDuroure , I was busy in travelling last couple of weeks so haven't got enough time. I'll check soon-ish (I don't want to block this task so resigning)

Sorry @JulienDuroure , I was busy in travelling last couple of weeks so haven't got enough time. I'll check soon-ish (I don't want to block this task so resigning)
Pratik Borhade removed their assignment 2023-12-06 04:07:56 +01:00
Member

I see, this is due to BLI_findstring returning false id at: https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenkernel/intern/lib_id.cc#L2018

I think BLI_findstring should not be used here because two id names can be same.
Instead of id_name we can just pass ID pointer to BLI_libblock_ensure_unique_name
I'll make a PR tomorrow.

I see, this is due to `BLI_findstring` returning false id at: https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenkernel/intern/lib_id.cc#L2018 I think `BLI_findstring` should not be used here because two id names can be same. Instead of `id_name` we can just pass `ID` pointer to `BLI_libblock_ensure_unique_name` I'll make a PR tomorrow.
Pratik Borhade self-assigned this 2023-12-15 18:18:53 +01:00

This is a duplicate of #71244

The issue is long known, but there was never a definitive answer to how to manage these names collisions during rename.

This is a duplicate of #71244 The issue is long known, but there was never a definitive answer to how to manage these names collisions during rename.
Member

The issue is long known, but there was never a definitive answer to how to manage these names collisions during rename.

add suffix to current ID we're renaming (like BLI_uniquename()), no? :)

Now I think my fix is wrong, otherwise you/Campbell would have fixed it by now :)

> The issue is long known, but there was never a definitive answer to how to manage these names collisions during rename. add suffix to current ID we're renaming (like `BLI_uniquename()`), no? :) Now I think my fix is wrong, otherwise you/Campbell would have fixed it by now :)
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-01-15 12:46:01 +01:00
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
5 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#115192
No description provided.