Correctly set up projects for converted boards

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6209
This commit is contained in:
Jon Evans 2020-11-28 22:45:56 -05:00
parent 5e117bfaa5
commit f78d909ffb
1 changed files with 18 additions and 19 deletions

View File

@ -584,29 +584,28 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD_SEXP; bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD_SEXP;
if( !converted ) // Loading a project should only be done under carefully considered circumstances.
// The calling code should know not to ask me here to change projects unless
// it knows what consequences that will have on other KIFACEs running and using
// this same PROJECT. It can be very harmful if that calling code is stupid.
SETTINGS_MANAGER* mgr = GetSettingsManager();
if( pro.GetFullPath() != mgr->Prj().GetProjectFullName() )
{ {
// Loading a project should only be done under carefully considered circumstances. // calls SaveProject
SaveProjectSettings();
// The calling code should know not to ask me here to change projects unless mgr->UnloadProject( &mgr->Prj() );
// it knows what consequences that will have on other KIFACEs running and using
// this same PROJECT. It can be very harmful if that calling code is stupid.
SETTINGS_MANAGER* mgr = GetSettingsManager();
if( pro.GetFullPath() != mgr->Prj().GetProjectFullName() ) mgr->LoadProject( pro.GetFullPath() );
{
// calls SaveProject
SaveProjectSettings();
mgr->UnloadProject( &mgr->Prj() ); // Do not allow saving a project if one doesn't exist. This normally happens if we are
// standalone and opening a board that has been moved from its project folder.
mgr->LoadProject( pro.GetFullPath() ); // For converted projects, we don't want to set the read-only flag because we want a project
// to be saved for the new file in case things like netclasses got migrated.
// Do not allow saving a project if one doesn't exist. This normally happens if we are if( !pro.Exists() && !converted )
// standalone and opening a board that has been moved from its project folder. Prj().SetReadOnly();
if( !pro.Exists() )
Prj().SetReadOnly();
}
} }
if( is_new ) if( is_new )