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

[email protected]
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
Ok thanks. 
At the moment even the most recent version of wxPython Classic (3.0.2.0) 
does not assert. Maybe one day Classic will do too...

r



Il giorno giovedì 20 luglio 2017 02:17:21 UTC+2, Robin Dunn ha scritto:
>
> [email protected] <javascript:> 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.