From dc90910e8d8f6fedb8b23a74ad6fc808b02c809b Mon Sep 17 00:00:00 2001
From: Damien Picard <dam.pic@free.fr>
Date: Sat, 16 Jul 2022 00:57:41 +0200
Subject: [PATCH] Fix T71100: Node Wrangler creates nodes on linked node trees

Change the global poll function to check that the node tree is not
from a library, disabling most Node Wrangler operators.

This fixes the issue, not only for material nodes as in the original
report, but also on compositing node trees from linked scenes and
geometry nodes.
---
 node_wrangler.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/node_wrangler.py b/node_wrangler.py
index 3b3fd0692..aa3b6bc25 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -822,11 +822,13 @@ def nw_check(context):
     space = context.space_data
     valid_trees = ["ShaderNodeTree", "CompositorNodeTree", "TextureNodeTree", "GeometryNodeTree"]
 
-    valid = False
-    if space.type == 'NODE_EDITOR' and space.node_tree is not None and space.tree_type in valid_trees:
-        valid = True
+    if (space.type == 'NODE_EDITOR'
+            and space.node_tree is not None
+            and space.node_tree.library is None
+            and space.tree_type in valid_trees):
+        return True
 
-    return valid
+    return False
 
 class NWBase:
     @classmethod
-- 
GitLab