Donkyhotay / pgu

Automatically exported from code.google.com/p/pgu
GNU Lesser General Public License v2.1
0 stars 0 forks source link

random crash due to NoneType #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Not 100% reproducible, but it occurs once every 20, 30 times.  I've created 
Buttons, and when the issues comes up, it comes up when you click on a Button.  
The python error messages are:

====================================
  File "somefile.py", line 45, in run
    self.app.event(e)
  File "...\gui\app.py", line 159, in event
    container.Container.event(self, ev)
  File "...\gui\container.py", line 189, in event
    used = w._event(sub)
  File "...\gui\widget.py", line 305, in _event
    return self.event(e)
  File "...\gui\theme.py", line 341, in func
    r = m(sub)
  File "...\gui\container.py", line 163, in event
    used = w._event(sub)
  File "...\gui\widget.py", line 305, in _event
    return self.event(e)
  File "...\gui\theme.py", line 337, in func
    'pos':(e.pos[0]-rect.x,e.pos[1]-rect.y),
AttributeError: 'NoneType' object has no attribute 'x'
=============================
Where i've replaced actual path with "..." or "somepath".

Like I said, usually the code runs; but once every 20 or 30 times, it crashes 
thus.

This is Windows 7 I'm using.

I'm curious, if this is something you have observed before?  Like if I should 
lower or increase the wait time in pygame.time.wait(20) in the main event loop.

Could you suggest a workaround to this, perhaps?  I'd be open to something like 
catching the error or something.  Thank you in advance.

Original issue reported on code.google.com by victor....@gmail.com on 12 Jan 2011 at 7:57

GoogleCodeExporter commented 9 years ago
Just want to say that, for now, I just added a try block arround the 
"self.app.event(e)" line, so right now it looks like:

try: 
  self.app.event(e)
except AttributeError as err:
  print(err)
  continue

Seems okay; but I don't know if it's safe to do something like this.  Please 
comment.  Thank you!

Original comment by victor....@gmail.com on 12 Jan 2011 at 8:04

GoogleCodeExporter commented 9 years ago
I haven't been able to reproduce this, so I'm not sure exactly what happens. 
I've added a check to the 'event' function in theme.py which should at least 
keep the application from crashing.

Original comment by peter.ro...@gmail.com on 6 Mar 2011 at 9:42