GPv3: Fix rename layers not updating RNA

Implement the same logic as we do for the active layer, by calling the
corresponding RNA function.

This makes sure all the notifiers and DEG update calls are properly
called. This is needed at least for !113908.

Also adds an undo push step which was missing in main.

Co-authored and reviewed (in real life) by: Julian Eisel <julian@blender.org>
This commit is contained in:
Dalai Felinto
2023-10-19 17:06:14 +02:00
parent 454c8fd866
commit cb0d260c4b

View File

@@ -208,9 +208,15 @@ class LayerViewItem : public AbstractTreeViewItem {
return true;
}
bool rename(const bContext & /*C*/, StringRefNull new_name) override
bool rename(const bContext &C, StringRefNull new_name) override
{
grease_pencil_.rename_node(layer_.as_node(), new_name);
PointerRNA layer_ptr = RNA_pointer_create(&grease_pencil_.id, &RNA_GreasePencilLayer, &layer_);
PropertyRNA *prop = RNA_struct_find_property(&layer_ptr, "name");
RNA_property_string_set(&layer_ptr, prop, new_name.c_str());
RNA_property_update(&const_cast<bContext &>(C), &layer_ptr, prop);
ED_undo_push(&const_cast<bContext &>(C), "Rename Grease Pencil Layer");
return true;
}