{"action":"opened","issue":{"url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/318","repository_url":"https://api.github.com/repos/wxWidgets/Phoenix","labels_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/318/labels{/name}","comments_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/318/comments","events_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/318/events","html_url":"https://github.com/wxWidgets/Phoenix/issues/318","id":223605529,"number":318,"title":"XRC subclassing crashes","user":{"login":"RobinD42","id":808502,"avatar_url":"https://avatars2.githubusercontent.com/u/808502?v=3","gravatar_id":"","url":"https://api.github.com/users/RobinD42","html_url":"https://github.com/RobinD42","followers_url":"https://api.github.com/users/RobinD42/followers","following_url":"https://api.github.com/users/RobinD42/following{/other_user}","gists_url":"https://api.github.com/users/RobinD42/gists{/gist_id}","starred_url":"https://api.github.com/users/RobinD42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobinD42/subscriptions","organizations_url":"https://api.github.com/users/RobinD42/orgs","repos_url":"https://api.github.com/users/RobinD42/repos","events_url":"https://api.github.com/users/RobinD42/events{/privacy}","received_events_url":"https://api.github.com/users/RobinD42/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-23T01:41:05Z","updated_at":"2017-04-23T01:41:05Z","closed_at":null,"body":"Moved from http://trac.wxwidgets.org/ticket/17773\r\n\r\nA while ago a crash was reported on wxpython-dev regarding XRC + subclasses. I'm encountering the same segmentation fault, and wondering how to solve it.\r\n\r\nHere's the repro code (adapted from the wxpython-dev message):\r\n\r\n```python\r\nimport wx\r\nimport wx.xrc as xrc\r\n\r\nxrc_data = \"\"\"\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<resource>\r\n  <object class=\"wxFrame\" name=\"MainFrame\">\r\n    <object class=\"wxPanel\" name=\"MainPanel\"\r\n            subclass=\"__main__.SubclassedPanel\">\r\n    </object>\r\n    <title>XRC Subclass Test</title>\r\n  </object>\r\n</resource>\r\n\"\"\"\r\n\r\nclass SubclassedPanel(wx.Panel):\r\n    def __init__(self, *args, **kwargs):\r\n        print(\"SubclassedPanel.__init__\", args, kwargs)\r\n        wx.Panel.__init__(self)\r\n        # Can't explicitly call self.Create() here, since we don't\r\n        # have our parent at this time.\r\n\r\nclass MyApp(wx.App):\r\n    def OnInit(self):\r\n        res = xrc.XmlResource()\r\n        res.LoadFromBuffer(xrc_data.strip().encode('utf-8'))\r\n        frame = res.LoadFrame(None, 'MainFrame') \r\n        frame.Show()\r\n        return True\r\n\r\nif __name__ == '__main__':\r\n    app = MyApp()\r\n    app.MainLoop()\r\n\r\n```\r\n\r\nThis reliably crashes wxPython 3.0.3.dev2700+c524ed1 osx-cocoa (phoenix), with similar results for the latest dev2749.\r\n\r\nCrash occurs in wxPanelXmlHandler::DoCreateResource(), but it doesn't really matter which widget class I subclass - all of them produce similar segmentation faults when attempting to create the object if the constructor hasn't called Create(). The problem is that widgets (other than the parent Frame) can't call Create() in init because at that time nothing is known about the parent widget.\r\n"}}
{"actor":{"display_login":"RobinD42"}}