Fix crash on shutdown if wxConfig couldn't be saved
If saving wxConfig to the file in wxAppConsoleBase::CleanUp() failed, wxLog messages were logged into a wxLogGui target which was recreated because wxTheApp is still non-null when CleanUp() is called. However it is destroyed soon afterwards and showing messages from wxLogGui without wxTheApp leads to crashes, at least in wxGTK. To avoid this, we could set wxTheApp to null before calling CleanUp(), but it's not clear if there is no cleanup code (or something called from it) which doesn't rely on wxTheApp existence, so instead just flush, and reset, the log target after calling CleanUp() but before destroying the application object. This fixes the crash which could be easily reproduced simply by making the file used by wxFileConfig not-writeable under Linux.
This commit is contained in:
parent
b90747d61a
commit
055c4cbed5
1 changed files with 7 additions and 3 deletions
|
|
@ -488,14 +488,18 @@ static void DoCommonPostCleanup()
|
|||
|
||||
void wxEntryCleanup()
|
||||
{
|
||||
DoCommonPreCleanup();
|
||||
|
||||
|
||||
// delete the application object
|
||||
if ( wxTheApp )
|
||||
{
|
||||
wxTheApp->CleanUp();
|
||||
}
|
||||
|
||||
// It's important to call this after wxApp::CleanUp() as it can log some
|
||||
// messages that will be flushed inside DoCommonPreCleanup().
|
||||
DoCommonPreCleanup();
|
||||
|
||||
if ( wxTheApp )
|
||||
{
|
||||
// reset the global pointer to it to nullptr before destroying it as in
|
||||
// some circumstances this can result in executing the code using
|
||||
// wxTheApp and using half-destroyed object is no good
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue