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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user