[msw 2.8.7] Problem saving application settings when system is shut down

Eric Jensen ml at j-dev.de
Mon Apr 14 12:30:38 PDT 2008


Hello Vadim,

Friday, April 11, 2008, 7:54:46 PM, you wrote:

VZ>  So we clearly have to destroy all the existing windows from either
VZ> wxWindowMSW::HandleEndSession() or, if we want this to be configurable,
VZ> from wxEVT_END_SESSION handler in wxApp. If you (or anybody) else can write
VZ> a patch adding such handler, it would be great. Of course, writing it
VZ> should be simple enough, it's the testing part which risks to be
VZ> time-consuming.

i tried to implement what you described and looked through the
wx-sources if there was already a function that did that and found
wxApp::CleanUp(). I tried the following change:

void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
  if (GetTopWindow())
    GetTopWindow()->Close(true);

  // two new lines here
  this->CleanUp();
  this->ExitMainLoop();
}

This seems to work fine in the sample i tried and one of my own,
bigger and more complex application.

However i don't know the internal workings of wxwidgets well enough to
estimate any possible side-effects of this code. And i'm a little
concerned about what would happen, if Windows - for whatever reason -
does *not* forcefully kill the process. In that case i'd be cutting the
tree i'm sitting on by destroying all toplevel windows there (because
the code is in effect called by an event handler in wxTopLevelWindow)

Regards, Eric





More information about the wx-users mailing list