diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-05-18 13:00:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-05-18 13:57:40 +0300 |
commit | 4402c3006be5bac4debcc121047175db27476ec9 (patch) | |
tree | e694a333acde3ead956390ceaaa361b796daee7b /release/scripts/startup/bl_operators/node.py | |
parent | eaf3160f13ef5ee7233ead9625336251ecd4d8f4 (diff) |
WM: check missing space-data & constraints in poll functions
Without this, menu search prints many errors in some contexts.
Diffstat (limited to 'release/scripts/startup/bl_operators/node.py')
-rw-r--r-- | release/scripts/startup/bl_operators/node.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py index e0d0fc1e145..6150789ea10 100644 --- a/release/scripts/startup/bl_operators/node.py +++ b/release/scripts/startup/bl_operators/node.py @@ -120,7 +120,7 @@ class NodeAddOperator: def poll(cls, context): space = context.space_data # needs active node editor and a tree to add nodes to - return ((space.type == 'NODE_EDITOR') and + return (space and (space.type == 'NODE_EDITOR') and space.edit_tree and not space.edit_tree.library) # Default execute simply adds a node @@ -265,7 +265,7 @@ class NODE_OT_collapse_hide_unused_toggle(Operator): def poll(cls, context): space = context.space_data # needs active node editor and a tree - return ((space.type == 'NODE_EDITOR') and + return (space and (space.type == 'NODE_EDITOR') and (space.edit_tree and not space.edit_tree.library)) def execute(self, context): @@ -296,7 +296,7 @@ class NODE_OT_tree_path_parent(Operator): def poll(cls, context): space = context.space_data # needs active node editor and a tree - return (space.type == 'NODE_EDITOR' and len(space.path) > 1) + return (space and (space.type == 'NODE_EDITOR') and len(space.path) > 1) def execute(self, context): space = context.space_data @@ -315,6 +315,8 @@ class NODE_OT_active_preview_toggle(Operator): @classmethod def poll(cls, context): space = context.space_data + if space is None: + return False if space.type != 'NODE_EDITOR': return False if space.edit_tree is None: |