Give a timeslice to show Save Changes? dialog before things get ugly.

This also moves closing the existing project earlier to improve the
workflow -- so there's a chance that the main fix might not be needed
anymore, but it's still safer to not have a control-flow that crashes
rather than to just not use that control-flow.

Fixes https://gitlab.com/kicad/code/kicad/issues/9200
This commit is contained in:
Jeff Young 2021-09-21 11:11:01 +01:00
parent 65c9170b46
commit 23c76cccf3
2 changed files with 8 additions and 2 deletions

View File

@ -66,6 +66,11 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle,
if( schdlg.ShowModal() == wxID_CANCEL )
return;
// OK, we got a new project to open. Time to close any existing project before we go on
// to collect info about where to put the new one, etc. Otherwise the workflow is kind of
// disjoint.
CloseProject( true );
wxFileName sch( schdlg.GetPath() );
sch.SetExt( aSchFileExtension );
@ -171,8 +176,6 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle,
}
}
// Close the project and make the new one
CloseProject( true );
CreateNewProject( pro.GetFullPath(), false /* Don't create stub files */ );
LoadProject( pro );

View File

@ -411,6 +411,9 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
if( !Kiway().PlayersClose( false ) )
return false;
// Give a timeslice for the save-changes? dialog (and for the project to actually close)
wxSafeYield();
// Save the project file for the currently loaded project.
if( m_active_project )
{