I am facing a strange crash now. (I am using wx 2.8.9 on WinXP).
There is a frame. On that frame, click some button, a modal dialog pops out. Then on that dialog, click other button, another modal dialog pops out. Then quickly close these two dialogs one by one. Then the crash happens. Actually, it's an ASSERT!
It's in the wxwidgets-2.8.9\src\common\evtloopcmn.cpp:154 in the function of wxEventLoopManual::Exit()
Code: Select all
wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") );
After checking the wx code, I find something maybe the root cause.
Every-time when we create a modal dialog, wx will create a infinite loop for it and disable other toplevel windows. (You can see the source of wxWidgets-2.8.9\src\common\evtloopcmn.cpp, function is wxEventLoop::Run()).
Before starting the loop, wx will switch current active loop using
Code: Select all
wxEventLoopActivator activate(&ms_activeLoop, this);
And in this loop, wx will pend/dispatch events.
When you close the modal dialog (click the X button or something), other top-level windows will be enabled and the modal loop will be ended. wxEventLoopManual::Exit() will be called though event processing and in this function. A flag variable will be set.
Code: Select all
...
m_shouldExit = true;
...
OnExit()
...
Code: Select all
int wxEventLoopManual::Run()
{
...
if ( m_shouldExit )
{
while ( Pending() )
Dispatch();
break;
}
...
I don't read all code, so this solution is just an assumption.
Is there anyone met this problem before? Any solution to it?
Thanks.