Don't unload project out from under someone else.

(Can only currently happen if you import settings from the current
project, but will happen in even more cases once we do MDI.)

Possibly Sentry KICAD-169.
This commit is contained in:
Jeff Young 2023-08-18 22:17:06 +01:00
parent 57d3aef4cd
commit 6c5ec288a5
1 changed files with 8 additions and 2 deletions

View File

@ -154,8 +154,13 @@ void DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction( wxCommandEvent& event )
return;
wxFileName projectFn( importDlg.GetFilePath() );
bool alreadyLoaded = false;
if( !m_frame->GetSettingsManager()->LoadProject( projectFn.GetFullPath(), false ) )
if( m_frame->GetSettingsManager()->GetProject( projectFn.GetFullPath() ) )
{
alreadyLoaded = true;
}
else if( !m_frame->GetSettingsManager()->LoadProject( projectFn.GetFullPath(), false ) )
{
wxString msg = wxString::Format( _( "Error importing settings from project:\n"
"Project file %s could not be loaded." ),
@ -203,5 +208,6 @@ void DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction( wxCommandEvent& event )
->ImportSettingsFrom( file.m_NetSettings );
}
m_frame->GetSettingsManager()->UnloadProject( otherPrj, false );
if( !alreadyLoaded )
m_frame->GetSettingsManager()->UnloadProject( otherPrj, false );
}