Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/startup/bl_operators')
-rw-r--r--release/scripts/startup/bl_operators/clip.py61
-rw-r--r--release/scripts/startup/bl_operators/constraint.py15
-rw-r--r--release/scripts/startup/bl_operators/node.py8
-rw-r--r--release/scripts/startup/bl_operators/object.py2
-rw-r--r--release/scripts/startup/bl_operators/userpref.py2
-rw-r--r--release/scripts/startup/bl_operators/view3d.py3
6 files changed, 49 insertions, 42 deletions
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
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)
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:
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index 5a388047ddd..d61bed71cab 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -133,7 +133,7 @@ class SelectCamera(Operator):
scene = context.scene
view_layer = context.view_layer
view = context.space_data
- if view.type == 'VIEW_3D' and view.use_local_camera:
+ if view and view.type == 'VIEW_3D' and view.use_local_camera:
camera = view.camera
else:
camera = scene.camera
diff --git a/release/scripts/startup/bl_operators/userpref.py b/release/scripts/startup/bl_operators/userpref.py
index f77f00d2234..3969386bad7 100644
--- a/release/scripts/startup/bl_operators/userpref.py
+++ b/release/scripts/startup/bl_operators/userpref.py
@@ -590,7 +590,7 @@ class PREFERENCES_OT_addon_install(Operator):
name="Target Path",
items=(
('DEFAULT', "Default", ""),
- ('PREFS', "User Prefs", ""),
+ ('PREFS', "Preferences", ""),
),
)
diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py
index ff5bcdb034f..0fa82e36d20 100644
--- a/release/scripts/startup/bl_operators/view3d.py
+++ b/release/scripts/startup/bl_operators/view3d.py
@@ -208,7 +208,8 @@ class VIEW3D_OT_transform_gizmo_set(Operator):
@classmethod
def poll(cls, context):
- return context.area.type == 'VIEW_3D'
+ area = context.area
+ return area and (area.type == 'VIEW_3D')
def execute(self, context):
space_data = context.space_data