[Bf-blender-cvs] [4fe0ef5eabc] temp-attribute-processor: fix showing menu items of wrong tree type

Jacques Lucke noreply at git.blender.org
Thu May 27 12:51:41 CEST 2021


Commit: 4fe0ef5eabc387c439691563a41f93fbf8dee016
Author: Jacques Lucke
Date:   Mon May 24 16:57:31 2021 +0200
Branches: temp-attribute-processor
https://developer.blender.org/rB4fe0ef5eabc387c439691563a41f93fbf8dee016

fix showing menu items of wrong tree type

===================================================================

M	release/scripts/startup/nodeitems_builtins.py

===================================================================

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index c5e90f693d1..79527631c37 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -37,38 +37,42 @@ class SortedNodeCategory(NodeCategory):
         super().__init__(identifier, name, description, items)
 
 
+def is_node_tree_type_visible(context, idname):
+    space = context.space_data
+    if space.type != 'NODE_EDITOR':
+        return False
+    tree = space.edit_tree
+    if tree is None:
+        return space.tree_type == idname
+    return tree.bl_idname == idname
+
 class CompositorNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
-        return (context.space_data.type == 'NODE_EDITOR' and
-                context.space_data.tree_type == 'CompositorNodeTree')
+        return is_node_tree_type_visible(context, 'CompositorNodeTree')
 
 
 class ShaderNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
-        return (context.space_data.type == 'NODE_EDITOR' and
-                context.space_data.tree_type == 'ShaderNodeTree')
+        return is_node_tree_type_visible(context, 'ShaderNodeTree')
 
 
 class TextureNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
-        return (context.space_data.type == 'NODE_EDITOR' and
-                context.space_data.tree_type == 'TextureNodeTree')
+        return is_node_tree_type_visible(context, 'TextureNodeTree')
 
 
 class GeometryNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
-        return (context.space_data.type == 'NODE_EDITOR' and
-                context.space_data.tree_type == 'GeometryNodeTree')
+        return is_node_tree_type_visible(context, 'GeometryNodeTree')
 
 class AttributeNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
-        return (context.space_data.type == 'NODE_EDITOR' and
-                context.space_data.tree_type == 'AttributeNodeTree')
+        return is_node_tree_type_visible(context, 'AttributeNodeTree')
 
 
 # menu entry for node group tools



More information about the Bf-blender-cvs mailing list