Fix #139170: Regression: The Linked Node Group Socket Name is Editable

This probably have occured after migration from UIList. When nodetree ID
is linked form another file, disable the layout for individual rows and
the add/remove operator. Also tweak `supports_renaming()` function so that
individual tree element cannot be renamed when linked.

Pull Request: https://projects.blender.org/blender/blender/pulls/139269
This commit is contained in:
Pratik Borhade
2025-05-23 12:19:41 +02:00
committed by Pratik Borhade
parent 23bddef11a
commit 0ad79ca541
2 changed files with 10 additions and 2 deletions

View File

@@ -953,6 +953,7 @@ class NODE_PT_node_tree_interface(Panel):
split.template_node_tree_interface(tree.interface)
ops_col = split.column(align=True)
ops_col.enabled = tree.library is None
ops_col.operator_menu_enum("node.interface_item_new", "item_type", icon='ADD', text="")
ops_col.operator("node.interface_item_remove", icon='REMOVE', text="")
ops_col.separator()

View File

@@ -100,6 +100,10 @@ class NodeSocketViewItem : public BasicTreeViewItem {
void build_row(uiLayout &row) override
{
if (ID_IS_LINKED(&nodetree_)) {
uiLayoutSetEnabled(&row, false);
}
uiLayoutSetPropDecorate(&row, false);
uiLayout *input_socket_layout = &row.row(true);
@@ -142,7 +146,7 @@ class NodeSocketViewItem : public BasicTreeViewItem {
bool supports_renaming() const override
{
return true;
return !ID_IS_LINKED(&nodetree_);
}
bool rename(const bContext &C, StringRefNull new_name) override
{
@@ -186,6 +190,9 @@ class NodePanelViewItem : public BasicTreeViewItem {
void build_row(uiLayout &row) override
{
if (ID_IS_LINKED(&nodetree_)) {
uiLayoutSetEnabled(&row, false);
}
/* Add boolean socket if panel has a toggle. */
if (toggle_ != nullptr) {
uiLayout *toggle_layout = &row.row(true);
@@ -214,7 +221,7 @@ class NodePanelViewItem : public BasicTreeViewItem {
bool supports_renaming() const override
{
return true;
return !ID_IS_LINKED(&nodetree_);
}
bool rename(const bContext &C, StringRefNull new_name) override
{