wxApp::OnExit() not called - why???
Victor C.
vc6vc6 at gmail.com
Wed Jan 23 21:13:01 PST 2008
On 1/23/08, SAM <nospam at i.net> wrote:
>
> Well, it appears to be an infinite loop with enough yield time to allow the
> rest of the program on the gui thread to function.
>
> You'll need to introduce another way out of the loop, something that tests
> to see if the OnExit function has been been called. try putting a
> wxMessageBox in the event handler for your Exit menu item to verify that it
> is (or isn't) getting called. If it is, all you'll need to do is change a
> (global?) variable to tell your infinite loop to stop. I'd probably guard
> that variable with a critical section locker, both in the OnExit function
> and in your loop.
>
Seth, thanks for your answer. I presume that you meant "loop with
*not* enough yield time to allow...", right?
Anyway, the way out of the loop is actually by OnExit... It is
wxApp::OnExit() that sets the hExitLoop event (oops... I forgot to
show the 'break' statement after the wxLogMessage).
So, my problem is that while all other messages/events in the system
get processed and generate their usual and expected behavior, only
OnExit() is not generated. This is strange: the corresponding menu
item gets selected, but OnExit() won't fire...
I tried to use a debugger to see where this is stuck, but this is a
multi-thread program so it the debugger breaks most of the time in
unrelated threads. The log file actually shows that the above loop
keeps running all the time, so I must assume the culprit is there.
As I mentioned earlier, if I exit that loop (change the while(true) to
something else), OnExit is called.
I need some insight into what conditions could make OnExit() not being
called. The documentation says, for example, that if OnInit() failes,
then OnExit() won't be called. I have already verified that this is
not my case.
Any ideas?
BTW, I forgot to mention that I am using wxWidgets 2.6.3 on Windows XP
(Visual C++ 2005 EE).
Thanks,
Victor
More information about the wx-users
mailing list