[pydocview] Error when closing an SDI application with multiple
windows using File->Exit
Klaus Nowikow
klaus.nowikow at tuwien.ac.at
Thu Oct 11 04:39:04 PDT 2007
Hi!
I am using wxPython 2.8.4.0 on Linux.
When I open multiple documents in my pydocview SDI application,
each with its own view, I get this traceback when closing the app
by selecting "Exit" from the File menu:
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/lib/pydocview.py", line 2372, in OnExit
self.Destroy()
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14041, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the DocSDIFrame object has been deleted, attribute
access no longer allowed.
I learnded that I have to override the OnClose() method of my view so that
it closes the window - otherwise I get a PyDeadObjectError concerning the document
object:
def OnClose(self, deleteWindow=True):
# Call parent class
close = docview.View.OnClose(self, deleteWindow)
# Close frame
if close and deleteWindow:
self.GetFrame().Close(True)
return close
But the DocSDIFrame seems to try to destroy itself once more:
def OnExit(self, event):
"""
Called when the application is exitting.
"""
# In there, View.OnClose() gets called
if self._childView.GetDocumentManager().Clear(force = False):
self.Destroy() # <- Here the frame is deleted a second time => traceback
else:
event.Veto()
Do I have to handle the closing of the view another way?
Btw, the event object that is passed to OnExit() above is of type CommandEvent,
which does not have a Veto() method.
--
Klaus
More information about the wxpython-users
mailing list