Fix: GPv3 layer renaming when name is unchanged #111173

Merged
Pratik Borhade merged 3 commits from PratikPB2123/blender:gpv3-rename-outliner into main 2023-08-16 14:48:54 +02:00
Member

When old and new names of layers/groups are same, garbage string is
displayed. This is because oldname char pointer is referenced to
node.name. After function execution, oldname memory is freed in
interface_handler (see after.rename_orig), thus displays garbage
string.
Fix is to copy the content of oldname instead of referencing it.

When old and new names of layers/groups are same, garbage string is displayed. This is because `oldname` char pointer is referenced to `node.name`. After function execution, `oldname` memory is freed in `interface_handler` (see `after.rename_orig`), thus displays garbage string. Fix is to copy the content of `oldname` instead of referencing it.
Pratik Borhade added 1 commit 2023-08-16 11:38:44 +02:00
98792a1907 Fix: GPv3 layer renaming when name is unchanged
When old and new names of layers/groups are same, garbage string is
displaed. This is because `oldname` char pointer is referenced to
`node.name`. After function execution, `oldname` argument is freed in
`interface_handler` (see `after.rename_orig`), thus displays garbage
string.
Pratik Borhade requested review from Falk David 2023-08-16 11:38:54 +02:00
Author
Member

Guess we won't need the below block after this PR:

          std::string new_name(node.name);
          node.name = oldname;
Guess we won't need the below block after this PR: ``` std::string new_name(node.name); node.name = oldname; ```
Falk David reviewed 2023-08-16 12:00:45 +02:00
@ -864,6 +864,9 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
/* The node already has the new name set. To properly rename the node, we need to first
* store the new name, restore the old name in the node, and then call the rename
* function. */
if (strcmp(node.name, oldname) == 0) {
Member

If the issue is that the node.name points to oldname shouldn't this compare the pointers instead of the string?

If the issue is that the `node.name` points to `oldname` shouldn't this compare the pointers instead of the string?
Author
Member

node.name points to oldname after this if block (see line 871 in PR 😅 )

`node.name` points to oldname after this `if block` (see line 871 in PR 😅 )
Member

Ah, of course. Then I think the right thing to do is call STRNCPY(node.name, oldname); instead of node.name = oldname;

Ah, of course. Then I think the right thing to do is call `STRNCPY(node.name, oldname);` instead of `node.name = oldname;`
Pratik Borhade added 1 commit 2023-08-16 12:21:38 +02:00
Falk David requested changes 2023-08-16 13:09:47 +02:00
@ -867,2 +867,3 @@
std::string new_name(node.name);
node.name = oldname;
BLI_strncpy(node.name, oldname, sizeof(oldname));
Member

sizeof(oldname) is a pointer, this won't work. But you can use node.name = BLI_strdup(oldname) which will call strlen internally.

`sizeof(oldname)` is a pointer, this won't work. But you can use `node.name = BLI_strdup(oldname)` which will call `strlen` internally.
Pratik Borhade added 1 commit 2023-08-16 13:19:30 +02:00
Falk David approved these changes 2023-08-16 14:04:39 +02:00
Pratik Borhade merged commit 338e4ef090 into main 2023-08-16 14:48:54 +02:00
Pratik Borhade deleted branch gpv3-rename-outliner 2023-08-16 14:48:56 +02:00
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
2 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#111173
No description provided.