Python 2.7
wxPython 2.9.2.2 (2.8.11 is OK)
Windows 7 & OS X 10.7
I first had this problem with agw.FlatNotebook but while creating this sample found it also occurs with wx.Notebook (sorry, Andrea, for thinking it was a problem for you).
On a notebook page containing a panel, if I display a MessageDialog prior to closing it, with the panel as its parent, Python crashes - see attached runnable sample with various commented-out scenarios that do and don't affect it. I'm guessing at some kind of timing race. It's easily avoided but I don't think it should be happening.
Isn't this the reason for wx.SafeShowMessage - I got the impression that
it was - I think that it was.
Gadget/Steve
···
On 28/09/2011 3:19 PM, David Hughes wrote:
Python 2.7
wxPython 2.9.2.2 (2.8.11 is OK)
Windows 7 & OS X 10.7
I first had this problem with agw.FlatNotebook but while creating this
sample found it also occurs with wx.Notebook (sorry, Andrea, for
thinking it was a problem for you).
On a notebook page containing a panel, if I display a MessageDialog
prior to closing it, with the panel as its parent, Python crashes -
see attached runnable sample with various commented-out scenarios that
do and don't affect it. I'm guessing at some kind of timing race. It's
easily avoided but I don't think it should be happening.
Basically what's happening is that since it's a top-level window the dlg.Destroy() is putting the dlg on the pending delete list. (Items in that list are deleted in the next idle event processed by the wxApp.) When the notebook panel is deleted it is destroyed immediately, and as part of that all of the panel's children are destroyed. There is some code that should be preventing the dialog from being added to the pending delete list twice, and also to remove itself from the list if it is deleted early from some other place, so I'm not sure why the crash is happening. Perhaps there is another way around the checks that are already in place... I'll run through the debugger a bit and see if I can figure it out.
As you've seen using CallAfter didn't help because the function is called from the processing of the pending events, which happens before sending the next round of idle events. Other workarounds besides using wx.CallLater are:
* Use some other window as the parent, such as the panel's top-level parent.
* Use None for the parent.
* Don't call dlg.Destroy since you know that it will be destroyed when the panel is deleted.
···
On 9/28/11 7:19 AM, David Hughes wrote:
Python 2.7
wxPython 2.9.2.2 (2.8.11 is OK)
Windows 7 & OS X 10.7
I first had this problem with agw.FlatNotebook but while creating this
sample found it also occurs with wx.Notebook (sorry, Andrea, for
thinking it was a problem for you).
On a notebook page containing a panel, if I display a MessageDialog
prior to closing it, with the panel as its parent, Python crashes - see
attached runnable sample with various commented-out scenarios that do
and don't affect it. I'm guessing at some kind of timing race. It's
easily avoided but I don't think it should be happening.
This is still an issue in wxPython 3.0.0 (wxWidgets 3.0.0). Is it worth making a ticket?
···
On Wednesday, September 28, 2011 7:38:33 PM UTC-2:30, Robin Dunn wrote:
On 9/28/11 7:19 AM, David Hughes wrote:
Python 2.7
wxPython 2.9.2.2 (2.8.11 is OK)
Windows 7 & OS X 10.7
I first had this problem with agw.FlatNotebook but while creating this
sample found it also occurs with wx.Notebook (sorry, Andrea, for
thinking it was a problem for you).
On a notebook page containing a panel, if I display a MessageDialog
prior to closing it, with the panel as its parent, Python crashes - see
attached runnable sample with various commented-out scenarios that do
and don’t affect it. I’m guessing at some kind of timing race. It’s
easily avoided but I don’t think it should be happening.
Basically what’s happening is that since it’s a top-level window the
dlg.Destroy() is putting the dlg on the pending delete list. (Items in
that list are deleted in the next idle event processed by the wxApp.)
When the notebook panel is deleted it is destroyed immediately, and as
part of that all of the panel’s children are destroyed. There is some
code that should be preventing the dialog from being added to the
pending delete list twice, and also to remove itself from the list if it
is deleted early from some other place, so I’m not sure why the crash is
happening. Perhaps there is another way around the checks that are
already in place… I’ll run through the debugger a bit and see if I
can figure it out.
As you’ve seen using CallAfter didn’t help because the function is
called from the processing of the pending events, which happens before
sending the next round of idle events. Other workarounds besides using
wx.CallLater are:
Use some other window as the parent, such as the panel’s top-level parent.
Use None for the parent.
Don’t call dlg.Destroy since you know that it will be destroyed when
the panel is deleted.