Apologies for the vague question, but I've run into something really
bizarre. Has anyone encountered wxPython destroying a window without
being told to? One module in my program is doing this for no apparent
reason that I can detect, and the result is that the entire program
crashes. (This is why I'm not destroying Frame objects in the first
place - it invariably took down the entire app.) All I am doing is
creating a dialog-like Frame object, populating it with controls, and
calling frame.MakeModal(True), and when the user clicks the "Okay"
button, the control state is read out, the frame is closed, and that's
supposed to be it. Instead, once the frame closes, the GUI freezes
for up to a second, then crashes, and I get this on the console:
Python(3934,0x7fff7dec0960) malloc: *** error for object 0x104262650:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
This is the top part of the stack trace from OS X:
0 libwx_osx_cocoa-2.9.dylib 0x0000000101cb41f3
wxWindowBase::~wxWindowBase() + 387
1 libwx_osx_cocoa-2.9.dylib 0x0000000101ae670d
wxWindow::~wxWindow() + 1837
2 libwx_osx_cocoa-2.9.dylib 0x0000000101bd408e
wxControlBase::~wxControlBase() + 62
3 libwx_osx_cocoa-2.9.dylib 0x0000000101afb5e7
wxCheckBox::~wxCheckBox() + 55
4 libwx_osx_cocoa-2.9.dylib 0x0000000101cb845b
wxWindowBase::Destroy() + 43
5 libwx_osx_cocoa-2.9.dylib 0x0000000101cb84ad
wxWindowBase::DestroyChildren() + 61
6 libwx_osx_cocoa-2.9.dylib 0x0000000101ae6556
wxWindow::~wxWindow() + 1398
7 libwx_osx_cocoa-2.9.dylib 0x0000000101cfed25 wxPanel::~wxPanel() + 149
8 libwx_osx_cocoa-2.9.dylib 0x0000000101cb845b
wxWindowBase::Destroy() + 43
9 libwx_osx_cocoa-2.9.dylib 0x0000000101cb84ad
wxWindowBase::DestroyChildren() + 61
10 libwx_osx_cocoa-2.9.dylib 0x0000000101ae6556
wxWindow::~wxWindow() + 1398
11 _windows_.so 0x000000010468e912
wxPyScrolledWindow::~wxPyScrolledWindow() + 290
12 libwx_osx_cocoa-2.9.dylib 0x0000000101cb845b
wxWindowBase::Destroy() + 43
13 libwx_osx_cocoa-2.9.dylib 0x0000000101cb84ad
wxWindowBase::DestroyChildren() + 61
14 libwx_osx_cocoa-2.9.dylib 0x0000000101ae6556
wxWindow::~wxWindow() + 1398
15 libwx_osx_cocoa-2.9.dylib 0x0000000101cfed25 wxPanel::~wxPanel() + 149
16 libwx_osx_cocoa-2.9.dylib 0x0000000101cb845b
wxWindowBase::Destroy() + 43
17 libwx_osx_cocoa-2.9.dylib 0x0000000101cb84ad
wxWindowBase::DestroyChildren() + 61
18 libwx_osx_cocoa-2.9.dylib 0x0000000101ad99cd
wxNonOwnedWindow::~wxNonOwnedWindow() + 45
19 libwx_osx_cocoa-2.9.dylib 0x0000000101c13a62
wxFrameBase::~wxFrameBase() + 114
20 libwx_osx_cocoa-2.9.dylib 0x0000000101b3d992 wxFrame::~wxFrame() + 50
21 libwx_osx_cocoa-2.9.dylib 0x00000001019836de
wxAppConsoleBase::DeletePendingObjects() + 46
22 libwx_osx_cocoa-2.9.dylib 0x0000000101983805
wxAppConsoleBase::ProcessIdle() + 85
23 libwx_osx_cocoa-2.9.dylib 0x0000000101bb4b92
wxAppBase::ProcessIdle() + 18
24 libwx_osx_cocoa-2.9.dylib 0x0000000101b27507 wxApp::ProcessIdle() + 39
25 libwx_osx_cocoa-2.9.dylib 0x00000001019ba1ce
wxEventLoopBase::ProcessIdle() + 30
26 libwx_osx_cocoa-2.9.dylib 0x0000000101a7551a
wxCFEventLoop::CommonModeObserverCallBack(__CFRunLoopObserver*, int) +
90
Since everything is being called in C++, I have no way to insert
debugging statements in my Python code. But what really perplexes me
is why these windows are being deleted in the first place when I
didn't ask for this. All I could think of is that it might be some
kind of garbage collection, but even if I save a reference to the
window after it's closed, I still get this crash. What's more bizarre
is that if I click the Cancel button, which does almost exactly the
same thing but doesn't read out the control state first, the window
closes and doesn't crash. In either case, however, I am not calling
Destroy at any point.
Any ideas how to debug this? I have no idea how to reproduce it
independently, because none of the other modules in the same app have
this problem - it is just one specific set of windows that should be
no different than any other, but they always crash. I should mention
that while I'm working with 2.9.2.4, wxOSX-Coca, Python 2.7.2, OS
10.7, I also have a report of this happening from a user running
Ubuntu 10.04 with wxPython 2.8.12.1.
thanks,
Nat