Improve sheet schematic import messages and simplify code.

There was also a logic bug when the selected schematic was in a different
path than the current project and was already part of the current project.
The symbol library table reconciliation code was still run which was wrong.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/11075
This commit is contained in:
Wayne Stambaugh 2022-03-21 08:45:43 -04:00
parent b679a21651
commit e336a0e403
1 changed files with 191 additions and 189 deletions

View File

@ -206,8 +206,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) ); wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) ); wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
if( fileName.GetPathWithSep() == Prj().GetProjectPath() if( !prjScreens.HasSchematic( fullFilename ) )
&& !prjScreens.HasSchematic( fullFilename ) ) {
if( fileName.GetPathWithSep() == Prj().GetProjectPath() )
{ {
// A schematic in the current project path that isn't part of the current project. // A schematic in the current project path that isn't part of the current project.
// It's possible the user copied this schematic from another project so the library // It's possible the user copied this schematic from another project so the library
@ -221,9 +222,10 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
if( !newLibNames.IsEmpty() ) if( !newLibNames.IsEmpty() )
{ {
msg = _( "There are library names in the loaded schematic that are missing " msg = _( "There are library names in the selected schematic that are missing "
"from the project library table. This may result in broken symbol " "from the current project library table. This may result in broken "
"library links for the loaded schematic. Do you wish to continue?" ); "symbol library references for the loaded schematic.\n\n"
"Do you wish to continue?" );
wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ), wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxOK | wxCANCEL | wxCANCEL_DEFAULT |
wxCENTER | wxICON_QUESTION ); wxCENTER | wxICON_QUESTION );
@ -261,10 +263,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
{ {
if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() ) if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
{ {
msg = _( "The schematic to be imported appears to have been created as part of " msg = _( "The selected file was created as part of a different project. "
"a different project. This can result in symbol library links which " "Linking the file to this project may result in missing or "
"are missing from or clash with symbol library links in the global " "incorrect symbol library references.\n\n"
"symbol and/or current project symbol library table.\n\n"
"Do you wish to continue?" ); "Do you wish to continue?" );
wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ), wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxOK | wxCANCEL | wxCANCEL_DEFAULT |
@ -311,9 +312,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
if( missingLibNames ) if( missingLibNames )
{ {
msg = _( "There are library names in the loaded schematic that are missing " msg = _( "There are symbol library names in the selected schematic that "
"from the loaded schematic project library table. This may result " "are missing from the selected schematic project library table. "
"in broken symbol library links for the schematic. " "This may result in broken symbol library references.\n\n"
"Do you wish to continue?" ); "Do you wish to continue?" );
wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ), wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxOK | wxCANCEL | wxCANCEL_DEFAULT |
@ -374,7 +375,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
{ {
msg = _( "A duplicate library name that references a different library exists " msg = _( "A duplicate library name that references a different library exists "
"in the current library table. This conflict cannot be resolved and " "in the current library table. This conflict cannot be resolved and "
"may result in broken symbol library links for the schematic. " "may result in broken symbol library references.\n\n"
"Do you wish to continue?" ); "Do you wish to continue?" );
wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ), wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxOK | wxCANCEL | wxCANCEL_DEFAULT |
@ -433,6 +434,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
} }
} }
} }
}
SCH_SCREEN* newScreen = newSheet->GetScreen(); SCH_SCREEN* newScreen = newSheet->GetScreen();
wxCHECK_MSG( newScreen, false, "No screen defined for sheet." ); wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );