[wxPython-dev] 20070511 test build uploaded

Robin Dunn robin at alldunn.com
Tue May 15 10:54:27 PDT 2007


Waldemar Osuch wrote:
> Hi,
> 
>> A new test build of wxPython has been uploaded.
>>
>>    Version: 2.8.4.0.20070511
>>    URL:     http://wxPython.wxcommunity.com/preview/20070511
>>    Changes: http://wxPython.wxcommunity.com/preview/20070511/CHANGES.html
>>
> 
> Following will crash hard on WindowsXP with Python 2.5.1 when closing 
> the app.
>>>> win32
>>>> 2.5
>>>> 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
>>>> 2.8.4.0.20070511 (msw-unicode)
> 
> ------------------------------------
> import wx
> import sys
> 
> print sys.platform
> print sys.winver
> print sys.version
> print wx.version()
> 
> class MyFrame(wx.Frame):
>    def __init__(self, parent, title='Test'):
>        wx.Frame.__init__(self, parent, -1, title)
>        dirctrl = self.dirctrl = wx.GenericDirCtrl(self, -1)
>        dirctrl.Path = r'c:\temp'
>        dirctrl.TreeCtrl.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeChange)
> 
>    def OnTreeChange(self, evt):
>        print self.dirctrl.Path
>        pass
> 
> 
> app = wx.App(False)
> frame = MyFrame(None)
> frame.Show()
> app.MainLoop()
> -------------------------------------------------------------------
> 
> It looks that it crashes when I try to access self.dirctrl.Path and
> self.dirctrl is already gone.
> Should the EVT_TREE_SEL_CHANGED be fired during closing?

Yes, this is a known issue.  Basically as the tree is destroyed each 
item is removed, and if the item is selected then another will be 
selected so the first can be removed, and then another, etc.  A 
selection event will be sent each time it is changed.

The workaround is easy.  You can just test the widget:

	if self.dirctrl:
		print self.dirctrl.Path

or you can check if the deletion is in progress:

	if not self.IsBeingDestroyed():
		print self.dirctrl.Path


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-dev mailing list