diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index 8ee00d5768..d38ef63c1e 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -98,6 +98,11 @@ public: MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL ) override; + long long GetLibraryTimestamp() const override + { + return getModificationTime( m_lib_path ).GetValue().GetValue(); + } + bool IsFootprintLibWritable( const wxString& aLibraryPath ) override { return false; // until someone writes others like FootprintSave(), etc. diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index ccc75d24b2..fe0a68cd6f 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -280,7 +280,7 @@ GPCB_FPL_CACHE::GPCB_FPL_CACHE( GPCB_PLUGIN* aOwner, const wxString& aLibraryPat wxDateTime GPCB_FPL_CACHE::GetLibModificationTime() const { if( !m_lib_path.DirExists() ) - return wxDateTime::Now(); + return wxDateTime( 0.0 ); 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 ) { LOCALE_IO toggle; diff --git a/pcbnew/gpcb_plugin.h b/pcbnew/gpcb_plugin.h index 2d73231649..c5c898b1bf 100644 --- a/pcbnew/gpcb_plugin.h +++ b/pcbnew/gpcb_plugin.h @@ -74,6 +74,8 @@ public: bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ) override; + long long GetLibraryTimestamp() const override; + bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; //------------------------------------------------------------- diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 5e3efcebc2..3f5efb4b0e 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -358,11 +358,7 @@ public: * directory). * Timestamps should not be considered ordered; they either match or they don't. */ - virtual long long GetLibraryTimestamp() const - { - // Default implementation. - return 0; - } + virtual long long GetLibraryTimestamp() const = 0; /** * Function PrefetchLib diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 3275be545b..891a22f325 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -122,9 +122,10 @@ class FP_CACHE wxFileName m_lib_path; /// The path of the library. MODULE_MAP m_modules; /// Map of footprint file name per MODULE*. - bool m_cache_dirty; // Stored separately because it's expensive - // to check m_cache_timestamp against file. - long long m_cache_timestamp; // A timestamp for the footprint file. + bool m_cache_dirty; // Stored separately because it's expensive to check + // m_cache_timestamp against all the files. + long long m_cache_timestamp; // A hash of the timestamps for all the footprint + // files. public: 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 { - // 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 ) return wxDateTime::Now().GetValue().GetValue(); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 39237adac8..7e20aa936d 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -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 ) { if( !m_cache || m_cache->m_lib_path != aLibraryPath || diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h index 4538388bd3..f8390b18a3 100644 --- a/pcbnew/legacy_plugin.h +++ b/pcbnew/legacy_plugin.h @@ -69,7 +69,7 @@ class LEGACY_PLUGIN : public PLUGIN public: - //--------------------------------------------------- + //-------------------------------------------------------------- const wxString PluginName() const override { @@ -93,9 +93,11 @@ public: bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ) override; + long long GetLibraryTimestamp() const override; + bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; - //-------------------------------------------------- + //------------------------------------------------------------- typedef int BIU; diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h index c28f900698..138463825d 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h @@ -47,6 +47,12 @@ public: const wxString GetFileExtension() const override; + long long GetLibraryTimestamp() const override + { + // No support for libraries.... + return 0; + } + // ------------------------------------------------------ PCAD_PLUGIN();