Add more control over ID renaming behavior. #126996

Merged
Bastien Montagne merged 20 commits from mont29/blender:tmp-id-rename into main 2024-09-20 13:37:11 +02:00

This commit adds low-level logic in BKE to support three behaviors in
case of name conflict when renaming an ID:

  1. Always tweak new name of the renamed ID (never modify the other ID
    name).
  2. Always set requested name in renamed ID, modifying as needed the
    other ID name.
  3. Only modify the other ID name if it shares the same root name with the
    current renamed ID's name.

It also adds quite some changes to IDTemplate, Outliner code, and
RNA-defined UILayout code, and the lower-level UI button API, to allow
for the new behavior defined in the design (i.e. option three from above list).

When renaming from the UI either 'fails' (falls back to adjusted name) or forces
renaming another ID, an INFO report is displayed.

This commit also fixes several issues in existing code, especially
regarding undo handling in rename operations (which could lead to saving
the wrong name in undo step, and/or over-generating undo steps).

API wise, the bahavior when directly assigning a name to the ID.name
property remains unchanged (option one from the list above). But a new
API call ID.rename has been added, which offers all three behaviors.

Unittests were added to cover the new implemented behaviors (both at
BKE level, and the RNA/Py API).

This commit implements #119139 design.

This commit adds low-level logic in BKE to support three behaviors in case of name conflict when renaming an ID: 1. Always tweak new name of the renamed ID (never modify the other ID name). 2. Always set requested name in renamed ID, modifying as needed the other ID name. 3. Only modify the other ID name if it shares the same root name with the current renamed ID's name. It also adds quite some changes to IDTemplate, Outliner code, and RNA-defined UILayout code, and the lower-level UI button API, to allow for the new behavior defined in the design (i.e. option three from above list). When renaming from the UI either 'fails' (falls back to adjusted name) or forces renaming another ID, an INFO report is displayed. This commit also fixes several issues in existing code, especially regarding undo handling in rename operations (which could lead to saving the wrong name in undo step, and/or over-generating undo steps). API wise, the bahavior when directly assigning a name to the `ID.name` property remains unchanged (option one from the list above). But a new API call `ID.rename` has been added, which offers all three behaviors. Unittests were added to cover the new implemented behaviors (both at BKE level, and the RNA/Py API). This commit implements #119139 design.
Bastien Montagne added 1 commit 2024-08-30 19:33:33 +02:00
Add more control over ID renaming behavior.
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
f7d64cbad7
This commit adds low-level logic in BKE to support three behaviors in
case of name conflict when renaming an ID:
- Always tweak new name of the renamed ID (never modify the other ID
  name).
- Always set requested name in renamed ID, modifying as needed the
  other ID name.
- Only modify the other ID name if it shares the same root name with the
  current renamed ID's name.

It also adds quite some changes to IDTempalte and Outliner code, and the
lower-level UI button API, to allow for the new behavior defined in the
design (i.e. option three from above list).

This commit also fixes several issues in existing code, especially
regarding undo handling in rename operations (which could lead to saving
the wrong name in undo step, and/or over-generating undo steps).

API wise, the bahavior when directly assigning a name to the `ID.name`
property remains unchanged (option one from the list above). But a new
API `ID.rename` has been added, which offers all three behaviors.

This commit implements #119139 design.
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Author
Owner

@blender-bot build package

@blender-bot build package
Member

Unknown platform package. See documentation for details.

Unknown platform `package`. See [documentation](https://projects.blender.org/infrastructure/blender-bot/src/branch/main/README.md) for details.
Bastien Montagne added 2 commits 2024-09-02 18:30:30 +02:00
Add auto-detection of 'ID name' UI widget and relevant edit code.
Some checks failed
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
1729883e6e
Allows to ensure the same behavior accross the whole UI for ID name
properties UI widget.
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Bastien Montagne added 1 commit 2024-09-02 18:45:44 +02:00
Merge branch 'main' into tmp-id-rename
All checks were successful
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
c51a28cfbc
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Member

Feels pretty good to me like this 👍

I thought briefly about whether the suffix should be swapped on collision with the same prefix, rather than taking the lowest available value. But after thinking about it a bit, I think the current behavior regarding this is fine.

Feels pretty good to me like this 👍 I thought briefly about whether the suffix should be swapped on collision with the same prefix, rather than taking the lowest available value. But after thinking about it a bit, I think the current behavior regarding this is fine.
Bastien Montagne added 4 commits 2024-09-03 19:51:59 +02:00
Merge branch 'main' into tmp-id-rename
Some checks failed
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
a6cc9b9964
Author
Owner

@blender-bot build

@blender-bot build
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Author
Owner

@blender-bot package linux

@blender-bot package linux
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Bastien Montagne added 2 commits 2024-09-04 12:01:57 +02:00
Fix for dummy GCC.
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
97eebb6da9
Author
Owner

@blender-bot build linux

@blender-bot build linux
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Bastien Montagne requested review from Pablo Vazquez 2024-09-04 12:44:56 +02:00
Bastien Montagne requested review from Julian Eisel 2024-09-04 12:44:57 +02:00
Member

Nice! Can we tweak the report text a little?

Currently it is:

Another data-block was renamed to allow renaming this one to 'Cube'

It mentions the item that we've just typed, so it's not so relevant. Do we know at this point what new name the other data-block got? That could be more useful to know.

What do you think of:

Name in use. The matching data-block was renamed to ‘{new_name}’

Nice! Can we tweak the report text a little? Currently it is: > Another data-block was renamed to allow renaming this one to 'Cube' It mentions the item that we've just typed, so it's not so relevant. Do we know at this point what _new_ name the other data-block got? That could be more useful to know. What do you think of: > Name in use. The matching data-block was renamed to ‘{new_name}’
Author
Owner

No the new name (or other renamed ID) is not available from the code that generate the report... We could add it too, need to return a struct instead of a simple result value then though.

No the new name (or other renamed ID) is not available from the code that generate the report... We _could_ add it too, need to return a struct instead of a simple result value then though.
Bastien Montagne added 2 commits 2024-09-04 17:32:43 +02:00
Add more info to return data of BKE ID rename code.
Some checks failed
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
2cbd2eb497
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Bastien Montagne added 2 commits 2024-09-05 16:47:04 +02:00
Fix tests.
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
2450b1468e
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Bastien Montagne added 1 commit 2024-09-17 15:42:27 +02:00
Merge branch 'main' into tmp-id-rename
All checks were successful
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
6a8db5679a
Author
Owner

Would be good to get final review on this one now, it's already a tad late in release cycle for ideal merge window for that type of non-trivial changes...

Would be good to get final review on this one now, it's already a tad late in release cycle for ideal merge window for that type of non-trivial changes...
Author
Owner

@blender-bot build

@blender-bot build
Author
Owner

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR126996) when ready.
Member

Would be good to get final review on this one

Seems to work as expected! Much nicer. Thanks! +1 on my side

> Would be good to get final review on this one Seems to work as expected! Much nicer. Thanks! +1 on my side
Pablo Vazquez approved these changes 2024-09-18 17:39:27 +02:00
Julian Eisel requested changes 2024-09-19 14:59:06 +02:00
Dismissed
Julian Eisel left a comment
Member

On the UI code side this seems fine, didn't check much on the rest.

Just one small issue, I'm getting a warning:

warning: no previous declaration for ‘bool ED_id_rename(Main&, ID&, blender::StringRefNull)’ [-Wmissing-declarations]

I don't see ED_id_management.hh added to any CMake file, and it's not included in ed_id_management.cc.

On the UI code side this seems fine, didn't check much on the rest. Just one small issue, I'm getting a warning: ``` warning: no previous declaration for ‘bool ED_id_rename(Main&, ID&, blender::StringRefNull)’ [-Wmissing-declarations] ``` I don't see `ED_id_management.hh` added to any CMake file, and it's not included in `ed_id_management.cc`.
Bastien Montagne added 2 commits 2024-09-19 17:27:40 +02:00
Add missing include/header.
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
c52559a1d2
Author
Owner

@blender-bot build

@blender-bot build
Bastien Montagne requested review from Julian Eisel 2024-09-19 17:28:13 +02:00
Julian Eisel approved these changes 2024-09-19 17:29:33 +02:00
Bastien Montagne added 1 commit 2024-09-20 11:24:48 +02:00
Merge branch 'main' into tmp-id-rename
Some checks failed
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
6d3aeb750f
Author
Owner

@blender-bot build

@blender-bot build
Bastien Montagne added 1 commit 2024-09-20 11:38:27 +02:00
Merge branch 'main' into tmp-id-rename
Some checks failed
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
5814249bbf
Author
Owner

@blender-bot build

@blender-bot build
Bastien Montagne added 1 commit 2024-09-20 12:20:18 +02:00
Merge branch 'main' into tmp-id-rename
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
d209e77356
Author
Owner

@blender-bot build

@blender-bot build
Bastien Montagne merged commit 3e03576b09 into main 2024-09-20 13:37:11 +02:00
Bastien Montagne deleted branch tmp-id-rename 2024-09-20 13:37:16 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#126996
No description provided.