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