diff --git a/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp b/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp index a62d776233..b0d1e6ea0c 100644 --- a/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp +++ b/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp @@ -57,11 +57,10 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow() } catch( const IO_ERROR& ioe ) { - DisplayError( this, - wxString::Format( _( "Error occurred writing empty symbol library table " - "file.\n\n%s" ), - SYMBOL_LIB_TABLE::GetGlobalTableFileName(), - ioe.What() ) ); + DisplayError( this, wxString::Format( _( "Error occurred writing empty symbol library " + "table.\n\n%s" ), + SYMBOL_LIB_TABLE::GetGlobalTableFileName(), + ioe.What() ) ); return false; } @@ -81,8 +80,7 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow() // Make sure the symbol library table to copy actually exists. if( !fn.FileExists() ) { - DisplayError( this, - wxString::Format( _( "File \"%s\" not found." ), fn.GetFullPath() ) ); + DisplayError( this, wxString::Format( _( "File '%s' not found." ), fn.GetFullPath() ) ); return false; } @@ -95,9 +93,9 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow() } catch( const IO_ERROR& ioe ) { - DisplayError( this, - wxString::Format( _( "File \"%s\" is not a valid symbol library table " - "file.\n\n%s" ), fn.GetFullPath(), ioe.What() ) ); + DisplayError( this, wxString::Format( _( "'%s' is not a valid symbol library table.\n\n%s" ), + fn.GetFullPath(), + ioe.What() ) ); return false; } @@ -106,19 +104,18 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow() if( !symTableFileName.DirExists() && !symTableFileName.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) { - DisplayError( this, - wxString::Format( _( "Cannot create global library table path \"%s\"." ), - symTableFileName.GetPath() ) ); + DisplayError( this, wxString::Format( _( "Cannot create global library table path '%s'." ), + symTableFileName.GetPath() ) ); return false; } // Copy the global symbol library table file to the user config. if( !::wxCopyFile( fn.GetFullPath(), symTableFileName.GetFullPath() ) ) { - DisplayError( this, - wxString::Format( _( "Cannot copy global symbol library table " - "file:\n\n \"%s\"\n\n:to:\n\n\"%s\"." ), - fn.GetFullPath(), symTableFileName.GetFullPath() ) ); + DisplayError( this, wxString::Format( _( "Cannot copy global symbol library table file " + "'%s' to '%s'." ), + fn.GetFullPath(), + symTableFileName.GetFullPath() ) ); return false; } @@ -132,9 +129,9 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow() } catch( const IO_ERROR& ioe ) { - DisplayError( this, - wxString::Format( _( "Error occurred loading global symbol library table:" - "\n\n%s" ), ioe.What() ) ); + DisplayError( this, wxString::Format( _( "Error occurred loading global symbol library " + "table.\n\n%s" ), + ioe.What() ) ); return false; } diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 0831820155..22d2f14b98 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -675,8 +675,9 @@ int ERC_TESTER::TestLibSymbolIssues() { wxCHECK( m_schematic, 0 ); - wxString msg; - int err_count = 0; + SYMBOL_LIB_TABLE* libTable = m_schematic->Prj().SchSymbolLibTable(); + wxString msg; + int err_count = 0; SCH_SCREENS screens( m_schematic->Root() ); @@ -690,38 +691,65 @@ int ERC_TESTER::TestLibSymbolIssues() wxCHECK2( symbol, continue ); - LIB_PART* libSymbolInSchematic = screen->GetLibSymbols()[ - symbol->GetLibId().GetUniStringLibId() ]; + wxString libIdStr = symbol->GetLibId().GetUniStringLibId(); + LIB_PART* libSymbolInSchematic = screen->GetLibSymbols()[ libIdStr ]; wxCHECK2( libSymbolInSchematic, continue ); - LIB_PART* libSymbol = SchGetLibPart( symbol->GetLibId(), - m_schematic->Prj().SchSymbolLibTable() ); + wxString libName = symbol->GetLibId().GetLibNickname(); + LIB_TABLE_ROW* libTableRow = libTable->FindRow( libName ); + + if( !libTableRow ) + { + std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); + ercItem->SetItems( symbol ); + msg.Printf( _( "The current configuration does not include the library '%s'." ), + libName ); + ercItem->SetErrorMessage( msg ); + + markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); + break; + } + else if( !libTable->HasLibrary( libName, true ) ) + { + std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); + ercItem->SetItems( symbol ); + msg.Printf( _( "The library '%s' is not enabled in the current configuration." ), + libName ); + ercItem->SetErrorMessage( msg ); + + markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); + break; + } + + wxString symbolName = symbol->GetLibId().GetLibItemName(); + LIB_PART* libSymbol = SchGetLibPart( symbol->GetLibId(), libTable ); if( libSymbol == nullptr ) { std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); ercItem->SetItems( symbol ); - msg.Printf( "Library symbol link \"%s\" cannot be found in symbol library table", - symbol->GetLibId().GetUniStringLibId() ); + msg.Printf( "Symbol '%s' not found in symbol library '%s'", + symbolName, + libName ); ercItem->SetErrorMessage( msg ); markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); + break; } - else + + std::unique_ptr flattenedSymbol = libSymbol->Flatten(); + + if( *flattenedSymbol != *libSymbolInSchematic ) { - std::unique_ptr flattenedSymbol = libSymbol->Flatten(); + std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); + ercItem->SetItems( symbol ); + msg.Printf( "Symbol '%s' has been modified in library '%s'.", + symbolName, + libName ); + ercItem->SetErrorMessage( msg ); - if( *flattenedSymbol != *libSymbolInSchematic ) - { - std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); - ercItem->SetItems( symbol ); - msg.Printf( "Library symbol \"%s\" has been modified", - symbol->GetLibId().GetUniStringLibId() ); - ercItem->SetErrorMessage( msg ); - - markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); - } + markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); } } diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 3448b34448..c4be430464 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,6 @@ #include #include #include -#include // For some default values LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,