From 4402c3006be5bac4debcc121047175db27476ec9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 18 May 2021 20:00:51 +1000 Subject: WM: check missing space-data & constraints in poll functions Without this, menu search prints many errors in some contexts. --- release/scripts/startup/bl_operators/clip.py | 61 ++++++++++++---------------- 1 file changed, 25 insertions(+), 36 deletions(-) (limited to 'release/scripts/startup/bl_operators/clip.py') diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 0470f542c63..45d1ea98a8a 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -206,8 +206,8 @@ class CLIP_OT_filter_tracks(Operator): @classmethod def poll(cls, context): - space = context.space_data - return (space.type == 'CLIP_EDITOR') and space.clip + sc = context.space_data + return sc and (sc.type == 'CLIP_EDITOR') and sc.clip def execute(self, context): num_tracks = self._filter_values(context, self.track_threshold) @@ -221,8 +221,8 @@ class CLIP_OT_set_active_clip(Operator): @classmethod def poll(cls, context): - space = context.space_data - return space.type == 'CLIP_EDITOR' and space.clip + sc = context.space_data + return sc and (sc.type == 'CLIP_EDITOR') and sc.clip def execute(self, context): clip = context.space_data.clip @@ -268,8 +268,8 @@ class CLIP_OT_track_to_empty(Operator): @classmethod def poll(cls, context): - space = context.space_data - return space.type == 'CLIP_EDITOR' and space.clip + sc = context.space_data + return sc and (sc.type == 'CLIP_EDITOR') and sc.clip def execute(self, context): sc = context.space_data @@ -293,7 +293,7 @@ class CLIP_OT_bundles_to_mesh(Operator): @classmethod def poll(cls, context): sc = context.space_data - return (sc.type == 'CLIP_EDITOR') and sc.clip + return sc and (sc.type == 'CLIP_EDITOR') and sc.clip def execute(self, context): from bpy_extras.io_utils import unpack_list @@ -341,12 +341,8 @@ class CLIP_OT_delete_proxy(Operator): @classmethod def poll(cls, context): - if context.space_data.type != 'CLIP_EDITOR': - return False - sc = context.space_data - - return sc.clip + return sc and (sc.type == 'CLIP_EDITOR') and sc.clip def invoke(self, context, event): wm = context.window_manager @@ -424,12 +420,8 @@ class CLIP_OT_set_viewport_background(Operator): @classmethod def poll(cls, context): - if context.space_data.type != 'CLIP_EDITOR': - return False - sc = context.space_data - - return sc.clip + return sc and (sc.type == 'CLIP_EDITOR') and sc.clip def execute(self, context): sc = context.space_data @@ -563,13 +555,11 @@ class CLIP_OT_setup_tracking_scene(Operator): @classmethod def poll(cls, context): sc = context.space_data - - if sc.type != 'CLIP_EDITOR': - return False - - clip = sc.clip - - return clip and clip.tracking.reconstruction.is_valid + if sc and sc.type == 'CLIP_EDITOR': + clip = sc.clip + if clip and clip.tracking.reconstruction.is_valid: + return True + return False @staticmethod def _setupScene(context): @@ -1018,13 +1008,11 @@ class CLIP_OT_track_settings_as_default(Operator): @classmethod def poll(cls, context): sc = context.space_data - - if sc.type != 'CLIP_EDITOR': - return False - - clip = sc.clip - - return clip and clip.tracking.tracks.active + if sc and sc.type == 'CLIP_EDITOR': + clip = sc.clip + if clip and clip.tracking.tracks.active: + return True + return False def execute(self, context): sc = context.space_data @@ -1068,11 +1056,12 @@ class CLIP_OT_track_settings_to_track(Operator): @classmethod def poll(cls, context): - space = context.space_data - if space.type != 'CLIP_EDITOR': - return False - clip = space.clip - return clip and clip.tracking.tracks.active + sc = context.space_data + if sc and sc.type == 'CLIP_EDITOR': + clip = sc.clip + if clip and clip.tracking.tracks.active: + return True + return False def execute(self, context): space = context.space_data -- cgit v1.2.3