particle buttons gave errors when there was no particle system on an object.

This commit is contained in:
Campbell Barton 2009-06-06 12:48:56 +00:00
parent b770be4f1f
commit 47ca5cbea2

@ -6,8 +6,8 @@ def particle_panel_enabled(psys):
def particle_panel_poll(context): def particle_panel_poll(context):
psys = context.particle_system psys = context.particle_system
type = psys.settings.type if psys==None: return False
return psys != None and (type=='EMITTER' or type=='REACTOR'or type=='HAIR') return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR')
class ParticleButtonsPanel(bpy.types.Panel): class ParticleButtonsPanel(bpy.types.Panel):
__space_type__ = "BUTTONS_WINDOW" __space_type__ = "BUTTONS_WINDOW"
@ -15,9 +15,7 @@ class ParticleButtonsPanel(bpy.types.Panel):
__context__ = "particle" __context__ = "particle"
def poll(self, context): def poll(self, context):
psys = context.particle_system return particle_panel_poll(context)
type = psys.settings.type
return psys != None and (type=='EMITTER' or type=='REACTOR'or type=='HAIR')
class PARTICLE_PT_particles(ParticleButtonsPanel): class PARTICLE_PT_particles(ParticleButtonsPanel):
__idname__= "PARTICLE_PT_particles" __idname__= "PARTICLE_PT_particles"
@ -37,9 +35,9 @@ class PARTICLE_PT_particles(ParticleButtonsPanel):
#row.itemL(text="Viewport") #row.itemL(text="Viewport")
#row.itemL(text="Render") #row.itemL(text="Render")
type = psys.settings.type ptype = psys.settings.type
if(type!='EMITTER' and type!='REACTOR' and type!='HAIR'): if ptype not in ('EMITTER', 'REACTOR', 'HAIR'):
layout.itemL(text="No settings for fluid particles") layout.itemL(text="No settings for fluid particles")
return return
@ -94,8 +92,8 @@ class PARTICLE_PT_cache(ParticleButtonsPanel):
def poll(self, context): def poll(self, context):
psys = context.particle_system psys = context.particle_system
type = psys.settings.type if psys==None: return False
return psys != None and (type=='EMITTER' or type== 'REACTOR') return psys.settings.type in ('EMITTER', 'REACTOR')
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout