Delete windows before application on session end in wxMSW
When WM_ENDSESSION was received by the application, the wxApp object itself was shut down by calling OnExit() on it before all the TLWs were destroyed, which could be completely unexpected as during normal shutdown the order of events is exactly the reverse. In practice, this resulted in crashes in any application whose main window close event handler or dtor touched wxTheApp in any way (e.g. to save any configuration in the global wxConfig object destroyed by wxApp::OnExit()). See #9590 (sorry for missing the point before, ATS).
This commit is contained in:
@@ -839,6 +839,13 @@ void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
|
||||
if ( !wxTopLevelWindows.empty() )
|
||||
wxTopLevelWindows[0]->SetHWND(0);
|
||||
|
||||
// Destroy all the remaining TLWs before calling OnExit() to have the same
|
||||
// sequence of events in this case as in case of the normal shutdown,
|
||||
// otherwise we could have many problems due to wxApp being already
|
||||
// destroyed when window cleanup code (in close event handlers or dtor) is
|
||||
// executed.
|
||||
DeleteAllTLWs();
|
||||
|
||||
const int rc = OnExit();
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
Reference in New Issue
Block a user