From cb0d260c4b790b2590563e6242bf0bcd3bc0e07d Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 19 Oct 2023 17:06:14 +0200 Subject: [PATCH] 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 --- .../interface_template_grease_pencil_layer_tree.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc index cad54c3be3d..b9164f5e64a 100644 --- a/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc +++ b/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc @@ -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(C), &layer_ptr, prop); + + ED_undo_push(&const_cast(C), "Rename Grease Pencil Layer"); return true; }