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/constraint.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/constraint.py')
-rw-r--r-- | release/scripts/startup/bl_operators/constraint.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/constraint.py b/release/scripts/startup/bl_operators/constraint.py index 49fc6a04112..f18f3bb3a49 100644 --- a/release/scripts/startup/bl_operators/constraint.py +++ b/release/scripts/startup/bl_operators/constraint.py @@ -33,6 +33,11 @@ class CONSTRAINT_OT_add_target(Operator): bl_label = "Add Target" bl_options = {'UNDO', 'INTERNAL'} + @classmethod + def poll(cls, context): + constraint = getattr(context, "constraint", None) + return constraint + def execute(self, context): context.constraint.targets.new() return {'FINISHED'} @@ -46,6 +51,11 @@ class CONSTRAINT_OT_remove_target(Operator): index: IntProperty() + @classmethod + def poll(cls, context): + constraint = getattr(context, "constraint", None) + return constraint + def execute(self, context): tgts = context.constraint.targets tgts.remove(tgts[self.index]) @@ -58,6 +68,11 @@ class CONSTRAINT_OT_normalize_target_weights(Operator): bl_label = "Normalize Weights" bl_options = {'UNDO', 'INTERNAL'} + @classmethod + def poll(cls, context): + constraint = getattr(context, "constraint", None) + return constraint + def execute(self, context): tgts = context.constraint.targets total = sum(t.weight for t in tgts) |