Browse Source

Be more robust around filesystems that don't support timestamps (KICAD-R7V).

(cherry picked from commit 6b32815887)
9.0
Jeff Young 3 months ago
parent
commit
bfd88ffa18
  1. 2
      eeschema/sch_io/altium/sch_io_altium.cpp
  2. 3
      eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp
  3. 2
      eeschema/sch_io/eagle/sch_io_eagle.cpp
  4. 2
      eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp
  5. 2
      eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp
  6. 6
      pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp
  7. 27
      pcbnew/pcb_io/eagle/pcb_io_eagle.cpp
  8. 17
      pcbnew/pcb_io/eagle/pcb_io_eagle.h
  9. 7
      pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp
  10. 3
      pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp

2
eeschema/sch_io/altium/sch_io_altium.cpp

@ -4774,7 +4774,7 @@ long long SCH_IO_ALTIUM::getLibraryTimestamp( const wxString& aLibraryPath ) con
if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
return fn.GetModificationTime().GetValue().GetValue();
else
return wxDateTime( 0.0 ).GetValue().GetValue();
return 0;
}

3
eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp

@ -298,10 +298,9 @@ void SCH_IO_CADSTAR_ARCHIVE::ensureLoadedLibrary( const wxString& aLibraryPath,
long long timestamp = 0;
wxFileName fn( aLibraryPath );
if( fn.IsFileReadable() )
if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
timestamp = fn.GetModificationTime().GetValue().GetValue();
if( fn.IsFileReadable()
&& m_cachePath == aLibraryPath
&& m_cachecsafn.GetFullPath() == csafn.GetFullPath()

2
eeschema/sch_io/eagle/sch_io_eagle.cpp

@ -542,7 +542,7 @@ long long SCH_IO_EAGLE::getLibraryTimestamp( const wxString& aLibraryPath ) cons
if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
return fn.GetModificationTime().GetValue().GetValue();
else
return wxDateTime( 0.0 ).GetValue().GetValue();
return 0;
}

2
eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp

@ -2250,7 +2250,7 @@ void SCH_IO_KICAD_LEGACY::CreateLibrary( const wxString& aLibraryPath,
m_cache = new SCH_IO_KICAD_LEGACY_LIB_CACHE( aLibraryPath );
m_cache->SetModified();
m_cache->Save( writeDocFile( aProperties ) );
m_cache->Load(); // update m_writable and m_mod_time
m_cache->Load(); // update m_writable and m_timestamp
}

2
eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp

@ -1662,7 +1662,7 @@ void SCH_IO_KICAD_SEXPR::CreateLibrary( const wxString& aLibraryPath,
m_cache = new SCH_IO_KICAD_SEXPR_LIB_CACHE( aLibraryPath );
m_cache->SetModified();
m_cache->Save();
m_cache->Load(); // update m_writable and m_mod_time
m_cache->Load(); // update m_writable and m_timestamp
}

6
pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp

@ -157,20 +157,14 @@ long long PCB_IO_ALTIUM_DESIGNER::GetLibraryTimestamp( const wxString& aLibraryP
{
// File hasn't been loaded yet.
if( aLibraryPath.IsEmpty() )
{
return 0;
}
wxFileName fn( aLibraryPath );
if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
{
return fn.GetModificationTime().GetValue().GetValue();
}
else
{
return 0;
}
}

27
pcbnew/pcb_io/eagle/pcb_io_eagle.cpp

@ -230,7 +230,7 @@ PCB_IO_EAGLE::PCB_IO_EAGLE() :
m_doneCount( 0 ),
m_lastProgressCount( 0 ),
m_totalCount( 0 ),
m_mod_time( wxDateTime::Now() )
m_timestamp( wxDateTime::Now().GetValue().GetValue() )
{
using namespace std::placeholders;
@ -3173,18 +3173,18 @@ void PCB_IO_EAGLE::centerBoard()
}
wxDateTime PCB_IO_EAGLE::getModificationTime( const wxString& aPath )
long long PCB_IO_EAGLE::GetLibraryTimestamp( const wxString& aPath ) const
{
// File hasn't been loaded yet.
if( aPath.IsEmpty() )
return wxDateTime::Now();
return wxDateTime::Now().GetValue().GetValue();
wxFileName fn( aPath );
if( fn.IsFileReadable() )
return fn.GetModificationTime();
if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
return fn.GetModificationTime().GetValue().GetValue();
else
return wxDateTime( 0.0 );
return 0;
}
@ -3194,14 +3194,9 @@ void PCB_IO_EAGLE::cacheLib( const wxString& aLibPath )
try
{
wxDateTime modtime = getModificationTime( aLibPath );
long long timestamp = GetLibraryTimestamp( aLibPath );
// Fixes assertions in wxWidgets debug builds for the wxDateTime object. Refresh the
// cache if either of the wxDateTime objects are invalid or the last file modification
// time differs from the current file modification time.
bool load = !m_mod_time.IsValid() || !modtime.IsValid() || m_mod_time != modtime;
if( aLibPath != m_lib_path || load )
if( aLibPath != m_lib_path || m_timestamp != timestamp )
{
wxXmlNode* doc;
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -3249,10 +3244,12 @@ void PCB_IO_EAGLE::cacheLib( const wxString& aLibPath )
loadLibrary( library, nullptr );
m_xpath->pop();
m_mod_time = modtime;
m_timestamp = timestamp;
}
}
catch(...){}
catch(...)
{
}
// TODO: Handle exceptions
// catch( file_parser_error fpe )
// {

17
pcbnew/pcb_io/eagle/pcb_io_eagle.h

@ -158,10 +158,7 @@ public:
bool aKeepUUID = false,
const std::map<std::string, UTF8>* aProperties = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override
{
return getModificationTime( aLibraryPath ).GetValue().GetValue();
}
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
bool IsLibraryWritable( const wxString& aLibraryPath ) override
{
@ -355,13 +352,13 @@ private:
unsigned m_lastProgressCount;
unsigned m_totalCount; ///< for progress reporting
int m_min_trace; ///< smallest trace we find on Load(), in BIU.
int m_min_hole; ///< smallest diameter hole we find on Load(), in BIU.
int m_min_via; ///< smallest via we find on Load(), in BIU.
int m_min_annulus; ///< smallest via annulus we find on Load(), in BIU.
int m_min_trace; ///< smallest trace we find on Load(), in BIU.
int m_min_hole; ///< smallest diameter hole we find on Load(), in BIU.
int m_min_via; ///< smallest via we find on Load(), in BIU.
int m_min_annulus; ///< smallest via annulus we find on Load(), in BIU.
wxString m_lib_path;
wxDateTime m_mod_time;
wxString m_lib_path;
long long m_timestamp;
};
#endif // PCB_IO_EAGLE_H_

7
pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp

@ -3015,7 +3015,12 @@ bool LP_CACHE::IsModified()
long long LP_CACHE::GetTimestamp( const wxString& aLibPath )
{
return wxFileName( aLibPath ).GetModificationTime().GetValue().GetValue();
wxFileName fn( aLibPath );
if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
return fn.GetModificationTime().GetValue().GetValue();
else
return 0;
}

3
pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp

@ -162,7 +162,8 @@ void FP_CACHE::Save( FOOTPRINT* aFootprintFilter )
m_cache_timestamp += fn.GetTimestamp();
}
m_cache_timestamp += m_lib_path.GetModificationTime().GetValue().GetValue();
if( m_lib_path.IsFileReadable() && m_lib_path.GetModificationTime().IsValid() )
m_cache_timestamp += m_lib_path.GetModificationTime().GetValue().GetValue();
// If we've saved the full cache, we clear the dirty flag.
if( !aFootprintFilter )

Loading…
Cancel
Save