Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxAppConsole abnormal termination when using event loop on user initiated app close #12930

wxtrac opened this issue Feb 10, 2011 · 2 comments


Copy link

@wxtrac wxtrac commented Feb 10, 2011

Issue migrated from trac ticket # 12930

component: base | priority: normal | resolution: invalid | keywords: wxAppConsole event loop abnormal termination

2011-02-10 18:34:27: Andrew.Smart (Andrew Smart) created the issue

I'm using a child class of wxAppConsole as the entry point.

When using an event loop, I claim that abnormal termination occurs when the user closes the program because:

  1. Any function set with cstdlib's atexit() function does not execute:
  2. No destructors are being executed.
  3. An overridden wxAppConsole::OnExit() method is not executed.
  4. No "program termination" event is given to an overridden wxAppConsole::FilterEvent(wxEvent&) method.

Abnormal termination occurs both with the Ctrl+C keyboard combination and the user pressing the X on the window.

All of the above succeed (the program terminates normally) when an event loop is NOT used (meaning wxAppConsole::OnRun() is overridden and a value successfully returned). All succeed except for # 4 above where I assume you'd need an event loop to "catch" that event in the first place.

I wrote a minimal test for you with #defines at top so you can change the event loop usage; program flow is written out to "Events.txt":

Joerg Toellner has noticed the same behavior:
"But i already do my cleanup in wxAppConsole::OnExit(). But somehow this is not called, when i exit the application other than returning from wxAppConsole::OnRun."
The advice in that thread was to use destructors to do cleanup, but at least in my case, no destructors are being executed.

This defect looks similar to but I think this is different.

My Environment: MS Windows 7. MS VS 2010. wxWidgets 66875. Unmodified setup.h.

My commands to build wxWidgets:

cd .\build\msw
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake" -f BUILD=release
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake" -f BUILD=debug
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\nmake" -f TARGET_CPU=AMD64 BUILD=release
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\nmake" -f TARGET_CPU=AMD64 BUILD=debug
Copy link
Collaborator Author

@wxtrac wxtrac commented Feb 19, 2011

2011-02-19 14:20:00: @vadz changed status from new to infoneeded_new

2011-02-19 14:20:00: @vadz commented

Sorry, I still (see my mailing list post) don't understand what do you mean by "user closes the program". If you mean "presses Ctrl-Break" then it's not surprising because the program is simply killed in this case. If you exit it gracefully somehow, please clarify how does it happen.

Copy link
Collaborator Author

@wxtrac wxtrac commented Feb 24, 2011

2011-02-24 00:24:36: Andrew.Smart (Andrew Smart) changed status from infoneeded_new to closed

2011-02-24 00:24:36: Andrew.Smart (Andrew Smart) set resolution to invalid

2011-02-24 00:24:36: Andrew.Smart (Andrew Smart) commented

I responded to the mailing list post; thank you:

I was not exiting gracefully somehow. My mistake was assuming wxAppConsole::OnExit would be called even when not exiting gracefully.

@wxtrac wxtrac closed this Feb 24, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant