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
1 changed files with 3 additions and 1 deletions

View File

@ -864,8 +864,10 @@ 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 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?

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 😅 )

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;`
std::string new_name(node.name);
node.name = oldname;
node.name = BLI_strdup(oldname);

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.
if (node.is_group()) {
grease_pencil.rename_group(node.as_group_for_write(), new_name);
}