Re: wx.menu.Insert leads to StackHash error when the program closes
Scott Talbert <[email protected]> Mon, 16 Jul 2018 23:08:30 -0400 (EDT)
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 16 Jul 2018, ABC wrote: > I ported my code from Python 2.7/wxPython 3.0.2 to Python 3.7/wxPython > 4.0.3, on Windows 7 32-bit. > I use PopupMenu() with a menu that has a sub-menu. > That sub-menu is added to the menu with Insert(). > Now, everytime the program exits, I get a StachHash_0a9e fault from Windows. > If I use Prepend() instead, all is good. > > The code below demonstrates this issue. > I also see that in this code, defining self.menu ahead of self.submenu, will > make the error go away. > > import wx > class Main_Frame(wx.Frame): > def __init__(self): > wx.Frame.__init__(self, parent = None, id = -1, title = 'Test menu > insert', style = wx.DEFAULT_FRAME_STYLE) > > self.submenu = wx.Menu() > self.submenu.Append(-1, 'Sub-menu') > > self.menu = wx.Menu() > > # ---- Insert vs. Prepend ---- > self.menu.Insert(0, -1, '...to sub-menu', self.submenu) > #self.menu.Prepend(-1, '...to sub-menu', self.submenu) > > class App(wx.App): > def __init__(self, redirect_ = False, redirect_filename_ = None): > wx.App.__init__(self, redirect = redirect_, filename = > redirect_filename_) > > def OnInit(self): > self.frame = Main_Frame() > > self.frame.Show() > self.SetTopWindow(self.frame) > > self.frame.PopupMenu(self.frame.menu, (10,10)) > return True > > def main(): > app = App() > app.MainLoop() > return False > > if __name__ == '__main__': > main() This is a bug in the memory management code for Insert(). It looks like it is supposed to be set correctly, but its not getting set in the generated code for some reason. I filed this for you: https://github.com/wxWidgets/Phoenix/issues/931 Scott -- 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.