Move tool shutdown to after all cancel opportunities.

Fixes https://gitlab.com/kicad/code/kicad/issues/4401
This commit is contained in:
Jeff Young 2020-05-12 00:06:48 +01:00
parent 105f85e551
commit c66bf3df67
1 changed files with 8 additions and 9 deletions

View File

@ -491,10 +491,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
return;
}
// Shutdown all running tools ( and commit any pending change )
if( m_toolManager )
m_toolManager->ShutdownAllTools();
if( Kiface().IsSingle() )
{
LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
@ -516,7 +512,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
if( simFrame && !simFrame->Close() ) // Can close the simulator?
return;
if( sheetList.IsModified() )
{
wxFileName fileName = g_RootSheet->GetScreen()->GetFileName();
@ -530,6 +525,14 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
}
}
//
// OK, we're really closing now. No more returns after this.
//
// Shutdown all running tools ( and commit any pending change )
if( m_toolManager )
m_toolManager->ShutdownAllTools();
// Close the find dialog and preserve it's setting if it is displayed.
if( m_findReplaceDialog )
{
@ -546,9 +549,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
}
if( FindHierarchyNavigator() )
{
FindHierarchyNavigator()->Close( true );
}
SCH_SCREENS screens;
wxFileName fn;
@ -569,9 +570,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() && !g_RootSheet->GetScreen()->IsEmpty() )
{
UpdateFileHistory( fileName );
}
g_RootSheet->GetScreen()->Clear();