Skip to content

Commit

Permalink
Fix node group polling
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumCoderQC committed Feb 25, 2023
1 parent 696908f commit f969866
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
11 changes: 7 additions & 4 deletions blender/arm/logicnode/arm_node_group.py
Expand Up @@ -253,9 +253,10 @@ class ArmUngroupGroupTree(bpy.types.Operator):

@classmethod
def poll(cls, context):
if context.active_node and hasattr(context.active_node, 'group_tree'):
if context.active_node.group_tree is not None:
return True
if context.space_data.type == 'NODE_EDITOR':
if context.active_node and hasattr(context.active_node, 'group_tree'):
if context.active_node.group_tree is not None:
return True
return False

def execute(self, context):
Expand Down Expand Up @@ -316,7 +317,9 @@ class ArmAddCallGroupNode(bpy.types.Operator):

@classmethod
def poll(cls, context):
return context.space_data.tree_type == 'ArmLogicTreeType' and context.space_data.edit_tree
if context.space_data.type == 'NODE_EDITOR':
return context.space_data.edit_tree and context.space_data.tree_type == 'ArmLogicTreeType'
return False

def execute(self, context):
tree = context.space_data.path[-1].node_tree
Expand Down
6 changes: 6 additions & 0 deletions blender/arm/logicnode/arm_nodes.py
Expand Up @@ -978,6 +978,12 @@ def is_logic_node_context(context: bpy.context) -> bool:
"""Return whether the given bpy context is inside a logic node editor."""
return context.space_data.type == 'NODE_EDITOR' and context.space_data.tree_type == 'ArmLogicTreeType'

def is_logic_node_edit_context(context: bpy.context) -> bool:
"""Return whether the given bpy context is inside a logic node editor and tree is being edited."""
if context.space_data.type == 'NODE_EDITOR' and context.space_data.tree_type == 'ArmLogicTreeType':
return context.space_data.edit_tree
return False


def reset_globals():
global nodes
Expand Down
10 changes: 5 additions & 5 deletions blender/arm/logicnode/tree_variables.py
Expand Up @@ -91,7 +91,7 @@ class ARM_OT_TreeVariablePromoteNode(bpy.types.Operator):

@classmethod
def poll(cls, context):
if not arm.logicnode.arm_nodes.is_logic_node_context(context):
if not arm.logicnode.arm_nodes.is_logic_node_edit_context(context):
return False
tree: bpy.types.NodeTree = context.space_data.path[-1].node_tree
if tree is None:
Expand Down Expand Up @@ -145,7 +145,7 @@ class ARM_OT_TreeVariableMakeLocalNode(bpy.types.Operator):

@classmethod
def poll(cls, context):
if not arm.logicnode.arm_nodes.is_logic_node_context(context):
if not arm.logicnode.arm_nodes.is_logic_node_edit_context(context):
return False
tree: bpy.types.NodeTree = context.space_data.path[-1].node_tree
if tree is None:
Expand Down Expand Up @@ -179,7 +179,7 @@ class ARM_OT_TreeVariableVariableAssignToNode(bpy.types.Operator):

@classmethod
def poll(cls, context):
if not arm.logicnode.arm_nodes.is_logic_node_context(context):
if not arm.logicnode.arm_nodes.is_logic_node_edit_context(context):
return False
tree: bpy.types.NodeTree = context.space_data.path[-1].node_tree
if tree is None or len(tree.arm_treevariableslist) == 0:
Expand Down Expand Up @@ -261,7 +261,7 @@ class ARM_OT_AddVarGetterNode(bpy.types.Operator):

@classmethod
def poll(cls, context):
if not arm.logicnode.arm_nodes.is_logic_node_context(context):
if not arm.logicnode.arm_nodes.is_logic_node_edit_context(context):
return False
tree: bpy.types.NodeTree = context.space_data.path[-1].node_tree
return tree is not None and len(tree.arm_treevariableslist) > 0
Expand Down Expand Up @@ -311,7 +311,7 @@ class ARM_OT_AddVarSetterNode(bpy.types.Operator):

@classmethod
def poll(cls, context):
if not arm.logicnode.arm_nodes.is_logic_node_context(context):
if not arm.logicnode.arm_nodes.is_logic_node_edit_context(context):
return False
tree: bpy.types.NodeTree = context.space_data.path[-1].node_tree
return tree is not None and len(tree.arm_treevariableslist) > 0
Expand Down

0 comments on commit f969866

Please sign in to comment.