Pcbnew: GEDA plugin fixes and improvements.

Fix a bug in library cache modification check.  The Pcbnew footprint
file extension (.kicad_mod) was used instead of the GEDA footprint file
extension (.fp) which always caused the cache to reload on every library
call.

Allow for partially cached libraries rather.

Remove #ifdefed out exception throw in FootprintEnumerate().  Exceptions
should not be disabled in plugins.
This commit is contained in:
Wayne Stambaugh 2017-06-09 09:02:26 -04:00
parent 33e0758636
commit d37a33723a
1 changed files with 17 additions and 22 deletions

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2012-2017 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -326,11 +326,10 @@ void GPCB_FPL_CACHE::Load()
catch( const IO_ERROR& ioe )
{
if( !cacheErrorMsg.IsEmpty() )
cacheErrorMsg += "\n";
cacheErrorMsg += "\n\n";
cacheErrorMsg += ioe.What();
}
} while( dir.GetNext( &fpFileName ) );
// Remember the file modification time of library file when the
@ -338,10 +337,8 @@ void GPCB_FPL_CACHE::Load()
// reload the cache as needed.
m_mod_time = GetLibModificationTime();
#if 0
if( !cacheErrorMsg.IsEmpty() )
THROW_IO_ERROR( cacheErrorMsg );
#endif
}
@ -390,7 +387,7 @@ bool GPCB_FPL_CACHE::IsModified( const wxString& aLibPath, const wxString& aFoot
wxFileName fn = m_lib_path;
fn.SetName( it->second->GetFileName().GetName() );
fn.SetExt( KiCadFootprintFileExtension );
fn.SetExt( GedaPcbFootprintLibFileExtension );
if( !fn.FileExists() )
{
@ -989,30 +986,28 @@ wxArrayString GPCB_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath,
init( aProperties );
#if 1 // Set to 0 to only read directory contents, not load cache.
wxString errorMsg;
cacheLib( aLibraryPath );
// Some of the files may have been parsed correctly so we want to add the valid files to
// the library.
try
{
cacheLib( aLibraryPath );
}
catch( const IO_ERROR& ioe )
{
errorMsg = ioe.What();
}
const MODULE_MAP& mods = m_cache->GetModules();
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
{
ret.Add( FROM_UTF8( it->first.c_str() ) );
}
#else
wxString fpFileName;
wxString wildcard = wxT( "*." ) + GedaPcbFootprintLibFileExtension;
if( dir.GetFirst( &fpFileName, wildcard, wxDIR_FILES ) )
{
do
{
wxFileName fn( aLibraryPath, fpFileName );
ret.Add( fn.GetName() );
} while( dir.GetNext( &fpFileName ) );
}
#endif
if( !errorMsg.IsEmpty() )
THROW_IO_ERROR( errorMsg );
return ret;
}