New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wx.Menu.Insert() needs a /Transfer/ #931

Closed
swt2c opened this Issue Jul 17, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@swt2c
Copy link
Contributor

swt2c commented Jul 17, 2018

A user reported this from the mailing list. I can confirm that /Transfer/ isn't getting set on Insert() for some reason, even though it looks like the etg script should be setting it.

Bug report below:
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()
@swt2c

This comment has been minimized.

Copy link
Contributor

swt2c commented Jul 17, 2018

Ah, I see the problem in menu.py...
addTransferAnnotations() is called with 'subMenu' but one Insert() has 'submenu'.

@RobinD42

This comment has been minimized.

Copy link
Member

RobinD42 commented Jul 18, 2018

Thanks

@RobinD42

This comment has been minimized.

Copy link
Member

RobinD42 commented Jul 18, 2018

Fixed by #933

@RobinD42 RobinD42 closed this Jul 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment