[wxpython-users] error on destroy GenericDirCtrl

wxPython user mailing list, post #18,477
Author:
Date:
Subject:
 Thomas
 2008-07-18 15:50:13
 [wxpython-users] error on destroy GenericDirCtrl
Hi All,

I am the following error on destroying a dialog with GenricDirCtrl object.

####################code##############################
self.genericDirCtrl1 = wx.GenericDirCtrl(defaultFilter=0, dir='.',
filter="All files (*.*)|*.*|PDF files (*.pdf)|*.pdf",
id=wxID_DIALOG1GENERICDIRCTRL1, name='genericDirCtrl1',
parent=self.panel8, pos=wx.Point(47, 0), size=wx.Size(256,
176),
style=wx.DIRCTRL_SHOW_FILTERS | wx.DIRCTRL_3D_INTERNAL |
wx.SUNKEN_BORDER)
self.treeCtrl1=self.genericDirCtrl1.GetTreeCtrl()
self.treeCtrl1.Bind(wx.EVT_TREE_SEL_CHANGED,
self.OnTreeCtrl1TreeSelChanged)


I fixed it by setting the event to None on close.
#################################

################Error#############
Traceback (most recent call last):
File "E:\XXXX\gui\wxDialogAccPayable.py"
, line 1158, in OnTreeCtrl1TreeSelChanged
fullFilepath=self.genericDirCtrl1.GetPath();
File
"C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line
5673, in GetPath
return _controls_.GenericDirCtrl_GetPath(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion
"stringSrc.GetStringData()->IsValid()"
failed at ..\..\src\common\string.cpp(775) in wxStringBase::operator`='()
2008-07-18 15:25:47
Traceback (most recent call last):
File "E:\XXXX\gui\wxDialogAccPayable.py"
, line 1158, in OnTreeCtrl1TreeSelChanged
fullFilepath=self.genericDirCtrl1.GetPath();
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 1450
4, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the GenericDirCtrl object
has been d
eleted, attribute access no longer allowed.

########################################

cheers
Thomas
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Robin Dunn
 2008-07-18 12:12:12
 Re: [wxpython-users] error on destroy GenericDirCtrl
Thomas wrote:
> Hi All,
>
> I am the following error on destroying a dialog with GenricDirCtrl object.

> Traceback (most recent call last):
> File "E:\XXXX\gui\wxDialogAccPayable.py"
> , line 1158, in OnTreeCtrl1TreeSelChanged
> fullFilepath=self.genericDirCtrl1.GetPath();
> File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
> line 1450
> 4, in __getattr__
> raise PyDeadObjectError(self.attrStr % self._name)
> wx._core.PyDeadObjectError: The C++ part of the GenericDirCtrl object
> has been d
> eleted, attribute access no longer allowed.

You can also test the widget reference. When the C++ part of the widget
has been destroyed then the proxy object will evaluate to false, so you
can do something like this:


if not self.genericDirCtrl1:
return
# do whatever...


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

_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users