Commit 0224bc2f authored by Wayne Stambaugh's avatar Wayne Stambaugh

Fix but reading empty footprints in netlist. (fixes lp:1226283)

* Remove fp_lib token from board and s-expr netlist file format.
* Fix a bunch of Doxygen warnings.
* Remove some extra debug log messages.
parent 7de43e4a
......@@ -1173,7 +1173,6 @@ bool EDA_APP::SetFootprintLibTablePath()
if( m_commonSettings->Read( kicadFpLibPath, &path ) && wxFileName::DirExists( path ) )
{
wxSetEnv( wxT( "KISYSMOD" ), path );
wxLogDebug( wxT( "Setting $KISYSMOD=\"%s\"." ), GetChars( path ) );
return true;
}
......@@ -1199,7 +1198,6 @@ bool EDA_APP::SetFootprintLibTablePath()
if( modFileCount != 0 )
{
wxLogDebug( wxT( "Setting $KISYSMOD=\"%s\"." ), GetChars( bestPath ) );
wxSetEnv( wxT( "KISYSMOD" ), bestPath );
return true;
}
......
......@@ -190,7 +190,7 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString & aFootprintName )
#if defined( USE_FP_LIB_TABLE )
FPID fpid;
wxCHECK_MSG( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
wxString::Format( wxT( "<%s> is not a valid FPID." ),
GetChars( aFootprintName ) ) );
......
......@@ -103,7 +103,6 @@ void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR
// After (name), remaining (lib) elements are order independent, and in
// some cases optional.
bool sawType = false;
bool sawOpts = false;
bool sawDesc = false;
......@@ -460,11 +459,6 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
}
else
{
wxLogDebug( wxT( "Found component %s footprint %s in legacy library <%s>." ),
GetChars( component->GetReference() ),
GetChars( GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ),
GetChars( libPath ) );
wxString libNickname;
FP_LIB_TABLE* cur = this;
......@@ -481,9 +475,6 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
&& uri.Find( wxChar( '/' ) ) >= 0 )
uri.Replace( wxT( "/"), wxT( "\\" ) );
wxLogDebug( wxT( "Comparing legacy path <%s> to lib table path <%s>." ),
GetChars( libPath ), GetChars( uri ) );
if( uri == libPath )
{
libNickname = cur->rows[i].GetNickName();
......@@ -537,8 +528,6 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS
bool tableExists = true;
wxFileName fn = GetGlobalTableFileName();
wxLogDebug( wxT( "Loading global footprint table file: %s" ), GetChars( fn.GetFullPath() ) );
if( !fn.FileExists() )
{
tableExists = false;
......@@ -548,8 +537,6 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS
wxString fileName( wxT( "fp_global_table" ) );
fileName = wxGetApp().FindLibraryPath( fileName );
wxLogDebug( wxT( "Copying global footprint table from <%s>." ), GetChars( fileName ) );
// The fallback is to create an empty global footprint table for the user to populate.
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
{
......
......@@ -171,6 +171,12 @@ int FPID::Parse( const std::string& aId )
}
int FPID::Parse( const wxString& aId )
{
return Parse( std::string( TO_UTF8( aId ) ) );
}
FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
{
int offset = Parse( aId );
......
......@@ -12,7 +12,6 @@ fields
footprint
footprints
fp
fp_lib
lib
libpart
libparts
......
/**
* @file class_worksheet_layuout.cpp
* @file class_worksheet_layout.cpp
* @brief description of graphic items and texts to build a title block
*/
......
/**
* @file page_layout_default_description.cpp
* @file common/page_layout/page_layout_default_description.cpp
*/
/*
......
/**
* @file page_layout_reader.cpp
* @file common/page_layout/page_layout_reader.cpp
* @brief read an S expression of description of graphic items and texts
* to build a title block and page layout
*/
......
/**
* @file title_block_shape.cpp
* @file title_block_shapes.cpp
* @brief description of graphic items and texts to build a title block
*/
......
/**
* @file title_block_shape_gost.h
* @file title_block_shapes_gost.cpp
* @brief description of graphic items and texts to build a title block
* using GOST standard
*/
......
/**
* @file page_layout_default_description.cpp
* @file common/page_layout_default_description.cpp
*/
/*
......
/**
* @file page_layout_reader.cpp
* @file common/page_layout_reader.cpp
* @brief read an S expression of description of graphic items and texts
* to build a title block and page layout
*/
......
......@@ -72,7 +72,6 @@ font
fp_arc
fp_circle
fp_curve
fp_lib
fp_line
fp_poly
fp_text
......
......@@ -483,7 +483,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
#if defined( USE_FP_LIB_TABLE )
FPID fpid;
if( fpid.Parse( TO_UTF8( aFootprintName ) ) >= 0 )
if( fpid.Parse( aFootprintName ) >= 0 )
{
DisplayInfoMessage( this, wxString::Format( wxT( "Footprint ID <%s> is not valid." ),
GetChars( aFootprintName ) ) );
......
......@@ -22,7 +22,7 @@
*/
/**
* @file class_components_listbox.h
* @file class_components_listbox.cpp
*/
#include <fctsys.h>
......
......@@ -77,7 +77,7 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
#if defined( USE_FP_LIB_TABLE )
FPID fpid;
wxCHECK_RET( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0,
wxCHECK_RET( fpid.Parse( aFootprintName ) < 0,
wxString::Format( wxT( "<%s> is not a valid FPID." ),
GetChars( aFootprintName ) ) );
......
......@@ -360,7 +360,7 @@ public:
/**
* Function FindRowByURI
* returns a #ROW if aURE is found in this table or in any chained
* returns a #FP_LIB_TABLE::ROW if aURE is found in this table or in any chained
* fallBack table fragments, else NULL.
*/
const ROW* FindRowByURI( const wxString& aURI );
......
......@@ -82,6 +82,8 @@ public:
*/
int Parse( const std::string& aId );
int Parse( const wxString& aId );
/**
* Function GetLibNickname
* returns the logical library name portion of a FPID.
......
......@@ -599,6 +599,8 @@ public:
/**
* Populates the list from a S expr description stored in a string
* @param aPageLayout = the S expr string
* @param Append Do not delete old layout if true and append \a aPageLayout
* the existing one.
*/
void SetPageLayout( const char* aPageLayout, bool Append = false );
......
......@@ -509,7 +509,6 @@ public:
* Function SetCrossHairPosition
* sets the screen cross hair position to \a aPosition in logical (drawing) units.
* @param aPosition The new cross hair position.
* @param aGridOrigin Origin point of the snap grid.
* @param aSnapToGrid Sets the cross hair position to the nearest grid position to
* \a aPosition.
*
......@@ -520,7 +519,6 @@ public:
* Function GetCursorPosition
* returns the current cursor position in logical (drawing) units.
* @param aOnGrid Returns the nearest grid position at the current cursor position.
* @param aGridOrigin Origin point of the snap grid.
* @param aGridSize Custom grid size instead of the current grid size. Only valid
* if \a aOnGrid is true.
* @return The current cursor position.
......
/**
* @file pagelayout_editor/events_called_functions.cpp
* @file pagelayout_editor/events_functions.cpp
* @brief page layout editor command event functions.
*/
/*
......
/**
* @file pl_editor/files.cpp
* @file pagelayout_editor/files.cpp
*/
/*
......
/**
* @file invoke_pl_editor.h
* @file invoke_pl_editor_dialog.h
*/
/*
......
......@@ -283,10 +283,11 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
* A component need a reference, value, footprint name and a full time stamp
* The full time stamp is the sheetpath time stamp + the component time stamp
*/
FPID fpid;
wxString footprint;
wxString tmp;
wxString ref;
wxString value;
wxString footprintName;
wxString footprintLib;
wxString library;
wxString name;
wxString pathtimestamp, timestamp;
......@@ -313,13 +314,7 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
case T_footprint:
NeedSYMBOLorNUMBER();
footprintName = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_fp_lib:
NeedSYMBOLorNUMBER();
footprintLib = FROM_UTF8( CurText() );
footprint = FromUTF8();
NeedRIGHT();
break;
......@@ -370,10 +365,15 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
}
}
FPID fpid;
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid PFID in\nfile: <%s>\nline: %d\noffset: %d" ),
GetChars( CurSource() ), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
}
fpid.SetFootprintName( footprintName );
fpid.SetLibNickname( footprintName );
pathtimestamp += timestamp;
COMPONENT* component = new COMPONENT( fpid, ref, value, pathtimestamp );
component->SetName( name );
......
......@@ -869,7 +869,7 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
}
m_out->Print( aNestLevel, "(module %s",
m_out->Quotes( aModule->GetFPID().GetFootprintName() ).c_str() );
m_out->Quotes( aModule->GetFPID().Format() ).c_str() );
if( aModule->IsLocked() )
m_out->Print( 0, " locked" );
......@@ -877,10 +877,6 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
if( aModule->IsPlaced() )
m_out->Print( 0, " placed" );
if( !aModule->GetFPID().IsLegacy() )
m_out->Print( 0, " (fp_lib %s)",
m_out->Quotes( aModule->GetFPID().GetLibNickname() ).c_str() );
formatLayer( aModule );
if( !( m_ctl & CTL_OMIT_TSTAMPS ) )
......
......@@ -168,7 +168,9 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText ) throw( PARSE_ERRO
FPID fpid;
fpid.SetFootprintName( footprintName );
if( !footprintName.IsEmpty() )
fpid.SetFootprintName( footprintName );
COMPONENT* component = new COMPONENT( fpid, reference, value, timeStamp );
component->SetName( name );
m_netlist->AddComponent( component );
......
......@@ -224,7 +224,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
#else
FPID fpid;
wxCHECK_MSG( fpid.Parse( TO_UTF8( moduleName ) ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
wxString::Format( wxT( "Could not parse FPID string <%s>." ),
GetChars( moduleName ) ) );
......@@ -260,7 +260,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
#else
FPID fpid;
wxCHECK_MSG( fpid.Parse( TO_UTF8( moduleName ) ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
wxString::Format( wxT( "Could not parse FPID string <%s>." ),
GetChars( moduleName ) ) );
......
......@@ -197,7 +197,19 @@ bool CMP_READER::Load( NETLIST* aNetlist ) throw( IO_ERROR, PARSE_ERROR )
// assignment list. This is an usual case during the life of a design.
if( component )
{
component->SetFPID( FPID( footprint ) );
FPID fpid;
if( !footprint.IsEmpty() && fpid.Parse( footprint ) >= 0 )
{
wxString error;
error.Printf( _( "invalid PFID in\nfile: <%s>\nline: %d" ),
GetChars( m_lineReader->GetSource() ),
m_lineReader->LineNumber() );
THROW_IO_ERROR( error );
}
component->SetFPID( fpid );
}
else
{
......
......@@ -109,11 +109,10 @@ class COMPONENT
/// The #FPID of the footprint assigned to the component.
FPID m_fpid;
/// The #MODULE loaded for #m_footprintName found in #m_footprintLib.
/// The #MODULE loaded for #m_fpid.
std::auto_ptr< MODULE > m_footprint;
/// Set to true if #m_footprintName or #m_footprintLib was changed when the footprint
/// link file was read.
/// Set to true if #m_fpid was changed when the footprint link file was read.
bool m_footprintChanged;
static COMPONENT_NET m_emptyNet;
......
......@@ -1549,7 +1549,14 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
module->SetInitialComments( aInitialComments );
NeedSYMBOLorNUMBER();
fpid.SetFootprintName( FromUTF8() );
if( fpid.Parse( FromUTF8() ) >= 0 )
{
wxString error;
error.Printf( _( "invalid PFID in\nfile: <%s>\nline: %d\noffset: %d" ),
GetChars( CurSource() ), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
}
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
......@@ -1566,12 +1573,6 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
module->SetIsPlaced( true );
break;
case T_fp_lib:
NeedSYMBOLorNUMBER();
fpid.SetLibNickname( FromUTF8() );
NeedRIGHT();
break;
case T_layer:
module->SetLayer( parseBoardItemLayer() );
NeedRIGHT();
......
......@@ -24,7 +24,7 @@
*/
/**
* @file dialog_target_properties.cpp
* @file target_edit.cpp
* @brief Functions to edit targets (class #PCB_TARGET).
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment