wxPython Phoenix calls OnSize after wx.Frame is destroyed

I am porting pysvn Workbench from a python2.7 wxPython 2.8 world to python3.4 wxPython Phoenix world.

There is one problem that I do not think is my doing.

I click the close window button on the main window.

This will run:

    def OnCloseWindow( self, event ):
        if self.app.exitAppNow():
            self.DestroyLater()

Then I see:

Traceback (most recent call last):
  File "/Users/barry/wc/svn/pysvn-phoenix/WorkBench/Source/wb_frame.py", line 502, in OnSize
    if not self.IsMaximized():
RuntimeError: wrapped C/C++ object of type WbFrame has been deleted

Why did OnSize get called without a usable wx.Frame?

Barry

Barry Scott wrote:

I am porting pysvn Workbench from a python2.7 wxPython 2.8 world to python3.4 wxPython Phoenix world.

There is one problem that I do not think is my doing.

I click the close window button on the main window.

This will run:

     def OnCloseWindow( self, event ):
         if self.app.exitAppNow():
             self.DestroyLater()

Then I see:

Traceback (most recent call last):
   File "/Users/barry/wc/svn/pysvn-phoenix/WorkBench/Source/wb_frame.py", line 502, in OnSize
     if not self.IsMaximized():
RuntimeError: wrapped C/C++ object of type WbFrame has been deleted

Why did OnSize get called without a usable wx.Frame?

DestroyLater is supposed to not let that happen, but maybe it is just reducing the likelihood. I guess it would be possible that once the pending items are being processed that some other deferred action is changing the size of the frame before the destroy actually happens, and then the destroy happens and then the EVT_SIZE for that frame is pulled from the main event queue and processed.

A simple workaround in your case would be to add "if not self: return" at the beginning of the event handler.

···

--
Robin Dunn
Software Craftsman