PyDeadObjectError on exit

Hello,

I think this is a pretty common occurrence. When I exit my program, I
sometime get:

wx._core.PyDeadObjectError: The C++ part of the PlaybackControls
object has been deleted, attribute access no longer allowed.
File "C:\Documents and Settings\User\My Documents\Python Projects
\GarlicSim\run_gui.py", line 38, in <module>
  garlicsim_wx.start()
File "C:\Documents and Settings\User\My Documents\Python Projects
\GarlicSim\garlicsim_wx\garlicsim_wx\__init__.py", line 56, in start
  app.MainLoop()
File "C:\Python26\Lib\site-packages\wx\_core.py", line 8007, in
MainLoop
  wx.PyApp.MainLoop(self)
File "C:\Python26\Lib\site-packages\wx\_core.py", line 7303, in
MainLoop
  return _core_.PyApp_MainLoop(*args, **kwargs)
File "C:\Documents and Settings\User\My Documents\Python Projects
\GarlicSim\garlicsim_wx\garlicsim_wx\general_misc\flag_raiser.py",
line 64, in on_timer
  if getattr(self.window, self.attribute_name) is True:
File "C:\Python26\Lib\site-packages\wx\_core.py", line 14568, in
__getattr__
  raise PyDeadObjectError(self.attrStr % self._name)

Is this because there are timers trying to run after some of the
widgets were destroyed?

And the more important question, what would be a good solution for
this?

Thanks,
Ram.

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hello,

I think this is a pretty common occurrence. When I exit my program, I
sometime get:

wx._core.PyDeadObjectError: The C++ part of the PlaybackControls
object has been deleted, attribute access no longer allowed.

Is this because there are timers trying to run after some of the
widgets were destroyed?

Perhaps.

And the more important question, what would be a good solution for
this?

You can Stop() your timers when you start shutting down the application. Or you can add tests like this:

  if self.otherWindow:
    self.otherWindow.DoSomething()

where otherWindow is the widget that might have been destroyed already. This works because when the proxy object's __class__ is changed to _wxPyDeadObject it gains a __nonzero__ method that always returns False.

···

On 5/10/10 8:40 AM, cool-RR wrote:

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Is it possible to automatically stop all the timers in the application in my on_close handler? I don’t want to find each of them manually, I would like to have one way to stop all timers in the program. Is this possible?

If not, I’ll take the if self.otherWindow suggestion.

Ram.

···

On Mon, May 10, 2010 at 8:07 PM, Robin Dunn robin@alldunn.com wrote:

On 5/10/10 8:40 AM, cool-RR wrote:

Hello,

I think this is a pretty common occurrence. When I exit my program, I

sometime get:

wx._core.PyDeadObjectError: The C++ part of the PlaybackControls

object has been deleted, attribute access no longer allowed.

Is this because there are timers trying to run after some of the

widgets were destroyed?

Perhaps.

And the more important question, what would be a good solution for

this?

You can Stop() your timers when you start shutting down the application. Or you can add tests like this:

    if self.otherWindow:

            self.otherWindow.DoSomething()

where otherWindow is the widget that might have been destroyed already. This works because when the proxy object’s class is changed to _wxPyDeadObject it gains a nonzero method that always returns False.

Robin Dunn

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

I did it now and it seems to work well.

Thanks, Ram.

···

On Mon, May 10, 2010 at 10:48 PM, Robin Dunn robin@alldunn.com wrote:

On 5/10/10 12:49 PM, cool-RR wrote:

Is it possible to automatically stop all the timers in the application

in my on_close handler? I don’t want to find each of them manually, I

would like to have one way to stop all timers in the program. Is this

possible?

Not with wx but you can easily do it yourself. When you create a timer then register it with some global object, such as your wx.App derived class. When you want to stop them all then just iterate over the list of timers calling Stop on each of them.

Robin Dunn

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en