WM: avoid Python exceptions in poll functions
This commit is contained in:
parent
cfe25e6efb
commit
fa5cc84a0a
@ -40,7 +40,8 @@ def geometry_modifier_poll(context):
|
||||
|
||||
|
||||
def get_context_modifier(context):
|
||||
if context.area.type == 'PROPERTIES':
|
||||
area = context.area
|
||||
if (area is not None) and (area.type == 'PROPERTIES'):
|
||||
modifier = context.modifier
|
||||
else:
|
||||
ob = context.object
|
||||
|
@ -178,12 +178,8 @@ class ProjectApply(Operator):
|
||||
|
||||
def execute(self, _context):
|
||||
image_name = ProjectEdit._proj_hack[0] # TODO, deal with this nicer
|
||||
|
||||
try:
|
||||
image = bpy.data.images[image_name, None]
|
||||
except KeyError:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
image = bpy.data.images.get((image_name, None))
|
||||
if image is None:
|
||||
self.report({'ERROR'}, tip_("Could not find image '%s'") % image_name)
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
@ -655,6 +655,11 @@ class IsolateTypeRender(Operator):
|
||||
bl_label = "Restrict Render Unselected"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
ob = context.object
|
||||
return (ob is not None)
|
||||
|
||||
def execute(self, context):
|
||||
act_type = context.object.type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user