Add GetLibraryTimestamp to other plugins.

Fixes: lp:1752719
* https://bugs.launchpad.net/kicad/+bug/1752719
This commit is contained in:
Jeff Young 2018-03-02 20:41:37 +00:00
parent cb052b42a6
commit 33d925f631
8 changed files with 44 additions and 12 deletions

View File

@ -98,6 +98,11 @@ public:
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
const PROPERTIES* aProperties = NULL ) override; const PROPERTIES* aProperties = NULL ) override;
long long GetLibraryTimestamp() const override
{
return getModificationTime( m_lib_path ).GetValue().GetValue();
}
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override bool IsFootprintLibWritable( const wxString& aLibraryPath ) override
{ {
return false; // until someone writes others like FootprintSave(), etc. return false; // until someone writes others like FootprintSave(), etc.

View File

@ -280,7 +280,7 @@ GPCB_FPL_CACHE::GPCB_FPL_CACHE( GPCB_PLUGIN* aOwner, const wxString& aLibraryPat
wxDateTime GPCB_FPL_CACHE::GetLibModificationTime() const wxDateTime GPCB_FPL_CACHE::GetLibModificationTime() const
{ {
if( !m_lib_path.DirExists() ) if( !m_lib_path.DirExists() )
return wxDateTime::Now(); return wxDateTime( 0.0 );
return m_lib_path.GetModificationTime(); return m_lib_path.GetModificationTime();
} }
@ -1131,6 +1131,16 @@ bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPER
} }
long long GPCB_PLUGIN::GetLibraryTimestamp() const
{
// If we have no cache, return a number which won't match any stored timestamps
if( !m_cache )
return wxDateTime::Now().GetValue().GetValue();
return m_cache->GetLibModificationTime().GetValue().GetValue();
}
bool GPCB_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath ) bool GPCB_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
{ {
LOCALE_IO toggle; LOCALE_IO toggle;

View File

@ -74,6 +74,8 @@ public:
bool FootprintLibDelete( const wxString& aLibraryPath, bool FootprintLibDelete( const wxString& aLibraryPath,
const PROPERTIES* aProperties = NULL ) override; const PROPERTIES* aProperties = NULL ) override;
long long GetLibraryTimestamp() const override;
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
//-----</PLUGIN API>-------------------------------------------------------- //-----</PLUGIN API>--------------------------------------------------------

View File

@ -358,11 +358,7 @@ public:
* directory). * directory).
* Timestamps should not be considered ordered; they either match or they don't. * Timestamps should not be considered ordered; they either match or they don't.
*/ */
virtual long long GetLibraryTimestamp() const virtual long long GetLibraryTimestamp() const = 0;
{
// Default implementation.
return 0;
}
/** /**
* Function PrefetchLib * Function PrefetchLib

View File

@ -122,9 +122,10 @@ class FP_CACHE
wxFileName m_lib_path; /// The path of the library. wxFileName m_lib_path; /// The path of the library.
MODULE_MAP m_modules; /// Map of footprint file name per MODULE*. MODULE_MAP m_modules; /// Map of footprint file name per MODULE*.
bool m_cache_dirty; // Stored separately because it's expensive bool m_cache_dirty; // Stored separately because it's expensive to check
// to check m_cache_timestamp against file. // m_cache_timestamp against all the files.
long long m_cache_timestamp; // A timestamp for the footprint file. long long m_cache_timestamp; // A hash of the timestamps for all the footprint
// files.
public: public:
FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath ); FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath );
@ -2131,7 +2132,7 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo
long long PCB_IO::GetLibraryTimestamp() const long long PCB_IO::GetLibraryTimestamp() const
{ {
// If we have not cache, return a number which won't match any stored timestamps // If we have no cache, return a number which won't match any stored timestamps
if( !m_cache ) if( !m_cache )
return wxDateTime::Now().GetValue().GetValue(); return wxDateTime::Now().GetValue().GetValue();

View File

@ -3383,6 +3383,16 @@ void LP_CACHE::LoadModules( LINE_READER* aReader )
} }
long long LEGACY_PLUGIN::GetLibraryTimestamp() const
{
// If we have no cache, return a number which won't match any stored timestamps
if( !m_cache )
return wxDateTime::Now().GetValue().GetValue();
return m_cache->GetLibModificationTime().GetValue().GetValue();
}
void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath ) void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath )
{ {
if( !m_cache || m_cache->m_lib_path != aLibraryPath || if( !m_cache || m_cache->m_lib_path != aLibraryPath ||

View File

@ -69,7 +69,7 @@ class LEGACY_PLUGIN : public PLUGIN
public: public:
//-----<PLUGIN IMPLEMENTATION>---------------------------------------------- //-----<PLUGIN API>---------------------------------------------------------
const wxString PluginName() const override const wxString PluginName() const override
{ {
@ -93,9 +93,11 @@ public:
bool FootprintLibDelete( const wxString& aLibraryPath, bool FootprintLibDelete( const wxString& aLibraryPath,
const PROPERTIES* aProperties = NULL ) override; const PROPERTIES* aProperties = NULL ) override;
long long GetLibraryTimestamp() const override;
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
//-----</PLUGIN IMPLEMENTATION>--------------------------------------------- //-----</PLUGIN API>--------------------------------------------------------
typedef int BIU; typedef int BIU;

View File

@ -47,6 +47,12 @@ public:
const wxString GetFileExtension() const override; const wxString GetFileExtension() const override;
long long GetLibraryTimestamp() const override
{
// No support for libraries....
return 0;
}
// -----</PUBLIC PLUGIN API>------------------------------------------------- // -----</PUBLIC PLUGIN API>-------------------------------------------------
PCAD_PLUGIN(); PCAD_PLUGIN();