diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index 3158f6c3f4..f64850492b 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -63,6 +63,15 @@ void FP_LIB_TABLE_ROW::SetType( const wxString& aType ) } +bool FP_LIB_TABLE_ROW::LibraryExists() const +{ + if( plugin ) + return plugin->CanReadLibrary( GetFullURI() ); + + return false; +} + + FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) : LIB_TABLE( aFallBackTable ) { diff --git a/include/fp_lib_table.h b/include/fp_lib_table.h index 688fe07c27..74e88d38f0 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -67,6 +67,8 @@ public: */ void SetType( const wxString& aType ) override; + bool LibraryExists() const; + PCB_IO_MGR::PCB_FILE_T GetFileType() { return type; } protected: diff --git a/pcbnew/drc/drc_test_provider_library_parity.cpp b/pcbnew/drc/drc_test_provider_library_parity.cpp index 043627c6cf..39d8f1bf39 100644 --- a/pcbnew/drc/drc_test_provider_library_parity.cpp +++ b/pcbnew/drc/drc_test_provider_library_parity.cpp @@ -837,10 +837,10 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run() if( !reportProgress( ii++, (int) board->Footprints().size(), progressDelta ) ) return false; // DRC cancelled - LIB_ID fpID = footprint->GetFPID(); - wxString libName = fpID.GetLibNickname(); - wxString fpName = fpID.GetLibItemName(); - const LIB_TABLE_ROW* libTableRow = nullptr; + LIB_ID fpID = footprint->GetFPID(); + wxString libName = fpID.GetLibNickname(); + wxString fpName = fpID.GetLibItemName(); + const FP_LIB_TABLE_ROW* libTableRow = nullptr; if( libName.IsEmpty() ) { @@ -884,6 +884,20 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run() continue; } + else if( !libTableRow->LibraryExists() ) + { + if( !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) ) + { + std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES ); + msg.Printf( _( "The footprint library '%s' was not found." ), + libName ); + drcItem->SetErrorMessage( msg ); + drcItem->SetItems( footprint ); + reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER ); + } + + continue; + } auto cacheIt = libFootprintCache.find( fpID ); std::shared_ptr<FOOTPRINT> libFootprint;