[msw 2.8.7] Problem saving application settings when system
is shut down
Eric Jensen
ml at j-dev.de
Tue Apr 15 13:21:43 PDT 2008
Hello Vadim,
Monday, April 14, 2008, 9:48:05 PM, you wrote:
VZ> Normally the code should work fine when the event handler destroys the
VZ> object it was called on. However to make it totally "safe" we could call
VZ> exit() ourselves from here. This would have a (big) added benefit of
VZ> executing dtors of global objects too.
VZ> Could you please check if
VZ> void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
VZ> {
VZ> // Windows will terminate the process soon after we
VZ> // return from WM_ENDSESSION handler anyhow, so make
VZ> // sure we at least execute our cleanup code before
VZ> const int rc = OnExit();
VZ> wxEntryCleanup();
VZ> // calling exit() instead of ExitProcess() or not doing
VZ> // anything at all and being killed by Windows has the
VZ> // advantage of executing the dtors of global objects
VZ> exit(rc);
VZ> }
VZ> works correctly?
this code seems to work fine. I tested once again with a small sample
any my own application. I also tested it using the RMTool.exe from the
Vista SDK (which sends the WM_ENDSESSION, but does not kill the
application). I didn't have an debugging environment on the Vista
machine, just my logging output which looked fine. And Vista didn't
complain about anything either ;)
If this code makes it into the library, maybe it should be mentioned
in the docs that the wxApp dtor will not get called if the
WM_ENDSESSION is received, so if anyone has important cleanup code in
his dtor, he can move the code to wxApp::OnExit().
Thanks, Eric
More information about the wx-users
mailing list