Fix #120058: Crash on undo rename in edit mode #120099

Closed
Jake wants to merge 1 commits from Jake-Faulkner/blender:Fix-120058 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

Drop the check for the return of BKE_id_new_name_validate, as it doesn't indicate if the name changed. More correct would be to replace it with a check for if the new name is different than the old, but I don't see any neat way to do that from down here.

Other check might also be replaced with an assert, but I'm less sure about that?

Drop the check for the return of `BKE_id_new_name_validate`, as it doesn't indicate if the name changed. More correct would be to replace it with a check for if the new name is different than the old, but I don't see any neat way to do that from down here. Other check might also be replaced with an assert, but I'm less sure about that?
Jake added 1 commit 2024-03-31 00:21:01 +01:00
1af6a4e0cd Fix #120058: Crash on undo rename in edit mode
Drop the check for the return of `BKE_id_new_name_validate`, as it doesn't indicate if the name changed. More correct would be to replace it with a check for if the new name is different than the old, but I don't see any neat way to do that from down here.

Other check might also be replaced with an assert, but I'm less sure about that?
Iliya Katushenock added this to the Core project 2024-03-31 12:36:37 +02:00
Iliya Katushenock added the
Interest
Overrides
label 2024-03-31 12:36:54 +02:00
Member

Just noting that the regression was caused by 195bb4f8f5

Just noting that the regression was caused by 195bb4f8f5

@mod_moder can you explain me what is linked to overrides in this PR?

@mod_moder can you explain me _what_ is linked to overrides in this PR?

I am not really familiar with this code so that is simple: i see ID_IS_LINKED and os i link overrides here.

I am not really familiar with this code so that is simple: i see `ID_IS_LINKED` and os i link *overrides* here.
Bastien Montagne requested changes 2024-04-02 16:10:35 +02:00
Bastien Montagne left a comment
Owner

@Jake-Faulkner Thanks for the PR! You have correctly identified the cause of the issue, but the proposed solution here is not correct.

This function is only here to ensure that the name of the ID is unique, it can be called from other codepaths than renaming an existing ID.

I think the proper solution here is to finally have a new BKE_libblock_rename(Main &bmain, ID &id, StringRefNull old_name, StringRefNull new_name) function, which would ensure all required actions on ID rename are performed (afaik, at least two different code handle ID renaming: RNA, and the Outliner).

  • Check that old and new names are not identical, otherwise early-return.
  • Call BKE_main_namemap_remove_name with the old name.
  • Actually copy the new name to the ID's name.
  • Call BKE_libblock_ensure_unique_name.
  • Set bmain.is_memfile_undo_written to false.
@Jake-Faulkner Thanks for the PR! You have correctly identified the cause of the issue, but the proposed solution here is not correct. This function is only here to ensure that the name of the ID is unique, it can be called from other codepaths than renaming an existing ID. I think the proper solution here is to finally have a new `BKE_libblock_rename(Main &bmain, ID &id, StringRefNull old_name, StringRefNull new_name)` function, which would ensure all required actions on ID rename are performed (afaik, at least two different code handle ID renaming: RNA, and the Outliner). * Check that old and new names are not identical, otherwise early-return. * Call `BKE_main_namemap_remove_name` with the old name. * Actually copy the new name to the ID's name. * Call `BKE_libblock_ensure_unique_name`. * Set `bmain.is_memfile_undo_written` to false.
Bastien Montagne added
Module
Core
and removed
Interest
Overrides
labels 2024-04-02 16:11:23 +02:00
Member

I am not really familiar with this code so that is simple: i see ID_IS_LINKED and os i link overrides here.

When in doubt (and given the fact that ID_IS_LINKED is not relevant for the changes here), it is better to not do anything here then

> I am not really familiar with this code so that is simple: i see `ID_IS_LINKED` and os i link *overrides* here. When in doubt (and given the fact that `ID_IS_LINKED` is not relevant for the changes here), it is better to not do anything here then

@Jake-Faulkner Thanks again for identifying to source issue of this crash and for the PR,

Given the severity of the bug (and therefore the urgency to fix it, and get it to sink a bit in main before backporting to 4.1.1), I went ahead and created an alternate fix (!120196).

Turns out we already had a BKE_libblock_rename that did everything correctly, we 'just' needed to use it everywhere!

@Jake-Faulkner Thanks again for identifying to source issue of this crash and for the PR, Given the severity of the bug (and therefore the urgency to fix it, and get it to sink a bit in main before backporting to 4.1.1), I went ahead and created an alternate fix (!120196). Turns out we already had a `BKE_libblock_rename` that did everything correctly, we 'just' needed to use it everywhere!
Bastien Montagne closed this pull request 2024-04-03 08:57:24 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
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#120099
No description provided.