Load symbol library cache when creating a new cache.

Do not rely on buffering always being disabled to ensure the library gets
loaded when the cache didn't exist.

Use wxFileName::GetModificationTime() rather than trying to use our own
TimestampDir() to get a single library file modification time.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22191
This commit is contained in:
Wayne Stambaugh
2025-11-03 16:27:39 -05:00
parent 0b234b5297
commit e013691d02
2 changed files with 10 additions and 4 deletions
@@ -1603,11 +1603,16 @@ void SCH_IO_KICAD_SEXPR::cacheLib( const wxString& aLibraryFileName,
if( !m_cache || !m_cache->IsFile( aLibraryFileName ) || m_cache->IsFileChanged() )
{
bool isNewCache = false;
if( !m_cache )
isNewCache = true;
// a spectacular episode in memory management:
delete m_cache;
m_cache = new SCH_IO_KICAD_SEXPR_LIB_CACHE( aLibraryFileName );
if( !isBuffering( aProperties ) )
if( !isBuffering( aProperties ) || isNewCache )
m_cache->Load();
}
}
+4 -3
View File
@@ -30,6 +30,7 @@ SCH_IO_LIB_CACHE::SCH_IO_LIB_CACHE( const wxString& aFullPathAndFileName ) :
m_modHash( 1 ),
m_fileName( aFullPathAndFileName ),
m_libFileName( aFullPathAndFileName ),
m_fileModTime( 0 ),
m_isWritable( true ),
m_isModified( false )
{
@@ -72,14 +73,14 @@ long long SCH_IO_LIB_CACHE::GetLibModificationTime()
if( !fn.IsDir() )
{
m_isWritable = fn.IsFileWritable();
return fn.GetModificationTime().GetValue().GetValue();
}
else
{
m_isWritable = fn.IsDirWritable();
wildcard = wxS( "*." ) + wxString( FILEEXT::KiCadSymbolLibFileExtension );
return TimestampDir( fn.GetPath(), wildcard );
}
return TimestampDir( fn.GetPath(), wildcard );
}
@@ -97,7 +98,7 @@ bool SCH_IO_LIB_CACHE::IsFileChanged() const
return false;
if( !fn.IsDir() && fn.IsFileReadable() )
return TimestampDir( fn.GetPath(), fn.GetFullName() ) != m_fileModTime;
return fn.GetModificationTime().GetValue().GetValue() != m_fileModTime;
if( fn.IsDir() && fn.IsDirReadable() )
return TimestampDir( fn.GetPath(),