[pydocview] Segmentation fault when opening two SDI views with the same document

Klaus Nowikow klaus.nowikow at tuwien.ac.at
Mon Oct 1 07:59:05 PDT 2007


Klaus Nowikow wrote:
> In my application I'd like to be be able to open two or more
> views with one document. I had some problems with this, so I

Sorry, I just noticed that I forgot to mention that I want to use the SDI
interface.

> tried to change the pydocview demo in the samples folder to
> open two views instead of one by changing these lines in
> TextEditorApplication.OnInit():
> 
> if not docManager.GetDocuments() and docManager.GetFlags() & wx.lib.docview.DOC_SDI:
>     textTemplate.CreateDocument('', docview.DOC_NEW).OnNewDocument()
> 
> to:
> 
> if not docManager.GetDocuments() and docManager.GetFlags() & wx.lib.docview.DOC_SDI:
>     doc = textTemplate.CreateDocument('', wx.lib.docview.DOC_NEW)
>     doc.OnNewDocument()
>     textTemplate.CreateView(doc, 0)
> 
> I now get two windows, but when I close both of them (not with File/Exit, but using
> the window's Close button, the one that's top right in Windows) I get a segmentation
> fault. Is this the wrong way to open multiple views for a single document?

In my own application I get a traceback when I close one of the
windows and move the mouse over the other (see bottom of the message).

Could this be because the document references a CommandProcessor object,
which in turn references only one Edit menu (see the CommandProcessor.GetEditMenu()
method)? When closing the window, the respective menu will be deleted and the
CommandProcessor references a dead object.


Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/lib/pydocview.py", line 2435, in
ProcessUpdateUIEvent
    if docMgr.ProcessUpdateUIEvent(event):  # Let the views handle the event before the services
  File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/lib/docview.py", line 1803, in
ProcessUpdateUIEvent
    self.OnUpdateRedo(event)
  File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/lib/docview.py", line 1665, in
OnUpdateRedo
    doc.GetCommandProcessor().SetMenuStrings()
  File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/lib/docview.py", line 3150, in
SetMenuStrings
    undoItem = self.GetEditMenu().FindItemById(wx.ID_UNDO)
  File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line 13481, in __getattr__
    raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the Menu object has been deleted, attribute access no
longer allowed.





More information about the wxpython-users mailing list