Fix #120058: Undoing a rename while in edit mode crashes Blender. #120196

Merged
Bastien Montagne merged 1 commits from mont29/blender:tmp-120058 into main 2024-04-05 03:19:45 +02:00

The root of the issue, as identified by Jake-Faulkner in his PR
(!120099), was that after changes in commit 195bb4f8f5,
BKE_libblock_ensure_unique_name would not always correctly set
bmain->is_memfile_undo_written to false when an ID name was actually
modified.

However, after analyzing a bit more the code in ID renaming, it appeared
that BKE_libblock_ensure_unique_name was not needed and only made
things more confusing. Some ID renaming code (from RNA, the Outliner,
and some do_version areas) would then do some manual ID renaming
operations and then call it, instead of simply using the existing 'all
in one' BKE_libblock_rename function.

This commit removes BKE_libblock_ensure_unique_name and all of its
usages, and simplify all code previously using it by calling
BKE_libblock_rename instead.

NOTE: The only non-trivial (not-so-nice) aspect of this commit is the
changes needed in the Outliner renaming code, since here the name of the
ID is directly edited, before calling the rename function, so this edit
needs to be undone to allow calling the generic ID rename API.

The root of the issue, as identified by Jake-Faulkner in his PR (!120099), was that after changes in commit 195bb4f8f5, `BKE_libblock_ensure_unique_name` would not always correctly set `bmain->is_memfile_undo_written` to false when an ID name was actually modified. However, after analyzing a bit more the code in ID renaming, it appeared that `BKE_libblock_ensure_unique_name` was not needed and only made things more confusing. Some ID renaming code (from RNA, the Outliner, and some do_version areas) would then do some manual ID renaming operations and then call it, instead of simply using the existing 'all in one' `BKE_libblock_rename` function. This commit removes `BKE_libblock_ensure_unique_name` and all of its usages, and simplify all code previously using it by calling `BKE_libblock_rename` instead. NOTE: The only non-trivial (not-so-nice) aspect of this commit is the changes needed in the Outliner renaming code, since here the name of the ID is directly edited, before calling the rename function, so this edit needs to be undone to allow calling the generic ID rename API.
Bastien Montagne added 1 commit 2024-04-03 08:54:45 +02:00
Fix #120058: Undoing a rename while in edit mode crashes Blender.
All checks were successful
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.
68b10ca4ca
The root of the issue, as identified by Jake-Faulkner in his PR
(!120099), was that after changes in commit 195bb4f8f5,
`BKE_libblock_ensure_unique_name` would not always correctly set
`bmain->is_memfile_undo_written` to false when an ID name was actually
modified.

However, after analyzing a bit more the code in ID renaming, it appeared
that `BKE_libblock_ensure_unique_name` was not needed and only made
things more confusing. Some ID renaming code (from RNA, the Outliner,
and some do_version areas) would then do some manual ID renaming
operations and then call it, instead of simply using the existing 'all
in one' `BKE_libblock_rename` function.

This commit removes `BKE_libblock_ensure_unique_name` and all of its
usages, and simplify all code previously using it by calling
`BKE_libblock_rename` instead.

NOTE: The only non-trivial (not-so-nice) aspect of this commit is the
changes needed in the Outliner renaming code, since here the name of the
ID is directly edited, before calling the rename function, so this edit
needs to be undone to allow calling the generic ID rename API.
Author
Owner

@blender-bot build

@blender-bot build
Bastien Montagne requested review from Philipp Oeser 2024-04-03 09:01:19 +02:00
Bastien Montagne requested review from Pratik Borhade 2024-04-03 09:01:20 +02:00
Philipp Oeser approved these changes 2024-04-03 10:23:37 +02:00
Philipp Oeser left a comment
Member

I was a little worried that in comparison to BKE_libblock_ensure_unique_name, BKE_libblock_rename does not explicitly check

  • which_libbase returns nullptr
  • only asserts in case of !ID_IS_LINKED(id)

But for both of these I dont really see a way to actually run into? (at least not from the new places it is called)

So looks good to me.

I was a little worried that in comparison to `BKE_libblock_ensure_unique_name`, `BKE_libblock_rename` does not explicitly check - `which_libbase` returns nullptr - only asserts in case of `!ID_IS_LINKED(id)` But for both of these I dont really see a way to actually run into? (at least not from the new places it is called) So looks good to me.
Pratik Borhade approved these changes 2024-04-04 11:50:16 +02:00
Pratik Borhade left a comment
Member

hi, looks correct.

Thanks for fixing the crash 😅

hi, looks correct. Thanks for fixing the crash 😅
Author
Owner

@lichtwerk I think just asserting on linked data is fine. And indeed I do not see how a code could try to rename an ID from an unknown type, that check on null listbase was really not needed imho.

@lichtwerk I think just asserting on linked data is fine. And indeed I do not see how a code could try to rename an ID from an unknown type, that check on null listbase was really not needed imho.
Bastien Montagne merged commit cb66cc3028 into main 2024-04-05 03:19:45 +02:00
Bastien Montagne deleted branch tmp-120058 2024-04-05 03:19:48 +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
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
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
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
3 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#120196
No description provided.