dlg.Raise() causes segmentation fault. Why?

I have code that was working for me earlier today but now (perhaps because my computer is less busy) is generating a segmentation fault when the .Raise() is called.

The gist of the code where this occurs is this:

            dlg2 = wx.MessageDialog(self.GetTopLevelParent(),text,header,wx.OK|wx.CANCEL)
            dlg2.CenterOnParent()
            dlg2.Raise()  # crashes here on Mac (sometimes?)
            try:
                if dlg2.ShowModal() == wx.ID_OK: pass
            finally:
                dlg2.Destroy()

It seg faults on the .Raise() and runs fine if that commented out. I am not 100% sure why added the .Raise() (probably because the dialog was getting hidden), and I can live without it, but I’d really like to understand what would cause this. Also, FWIW, the CenterOnParent() is not moving the window on top of the parent.

I see this on a Mac and with wx 4.0.4 and 4.1.1.

Brian

Please provide a runnable sample.
Why do you need to call Raise at all? Doesn’t ShowModal place the dialog on top of the stack?
I’m not sure whether Raise makes sense to be called when the dialog is not shown yet.

This is another case of an issue due to the common dialogs, like the wx.MessageDialog not being a real wx.Dialog, but just a simple wrapper around the platform APIs for showing the platform’s dialog. If you need to do more than create, show and get the return value then you’ll need to make your own dialog derived from wx.Dialog. Most of the methods that don’t do anything should simply be ignored, but there may be some interaction with the base classes for Raise which is causing the segfault.