Re: pushing handlers, then forgetting to pop them, asserts in Phoenix

Robin Dunn <[email protected]>
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
[email protected] wrote:
> Hello,
> I've just found out that this will trigger an assert in Phoenix, when
> destroying the window:
>
> |class MyEvtHandler(wx.EvtHandler):
>     def __init__(self):
>         wx.EvtHandler.__init__(self)
>         self.Bind(wx.EVT_BUTTON, self.on_clic)
>
>     def on_clic(self, evt):
>         print("hello!")
>         evt.Skip()
>
> class MainFrame(wx.Frame):
>     def __init__(self, *a, **k):
>         wx.Frame.__init__(self, *a, **k)
>         button = wx.Button(self)
>         button.PushEventHandler(MyEvtHandler())|
>
> Now when you close the window you get an AssertionError. Apparently,
> we hit this assert in wxWidgets
> <https://github.com/wxWidgets/wxWidgets/blob/master/src/common/wincmn.cpp#L473>,
> checking that "Any additional event handlers should be popped before
> the window is deleted".
> Which is fine, except that I can't remember wxPython Classic ever
> complaining about this. Maybe the old machinery did a better job at
> cleaning up? Or I always been lucky and never experienced a crash
> because of an orphan handler?

Probably just lucky.  The assert wasn't there until sometime in the 2.9
release series, IIRC.  I've helped fix issues related to it in projects
using wxPython Classic 3.0.x so I know there wasn't anything hiding or
protecting you from the assert in Classic. (Unless perhaps you were
using a build that had assertions turned off.)

-- 
Robin Dunn
Software Craftsman
http://wxPython.org

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.