Add ADVANCED_CFG to always reload cached 3d models in memory

This commit is contained in:
Marek Roszko 2021-07-11 00:31:06 -04:00
parent 79b90813ec
commit 7cb0f8f808
3 changed files with 16 additions and 11 deletions

View File

@ -238,7 +238,7 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCach
if( fname.FileExists() ) // Only check if file exists. If not, it will if( fname.FileExists() ) // Only check if file exists. If not, it will
{ // use the same model in cache. { // use the same model in cache.
bool reload = false; bool reload = ADVANCED_CFG::GetCfg().m_Skip3DMemoryCache;
wxDateTime fmdate = fname.GetModificationTime(); wxDateTime fmdate = fname.GetModificationTime();
if( fmdate != mi->second->modTime ) if( fmdate != mi->second->modTime )
@ -292,17 +292,17 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
if( aCachePtr ) if( aCachePtr )
*aCachePtr = nullptr; *aCachePtr = nullptr;
unsigned char sha1sum[20]; unsigned char sha1sum[20];
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
m_CacheList.push_back( ep );
wxFileName fname( aFileName );
ep->modTime = fname.GetModificationTime();
if( !getSHA1( aFileName, sha1sum ) || m_CacheDir.empty() ) if( !getSHA1( aFileName, sha1sum ) || m_CacheDir.empty() )
{ {
// just in case we can't get a hash digest (for example, on access issues) // just in case we can't get a hash digest (for example, on access issues)
// or we do not have a configured cache file directory, we create an // or we do not have a configured cache file directory, we create an
// entry to prevent further attempts at loading the file // entry to prevent further attempts at loading the file
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
m_CacheList.push_back( ep );
wxFileName fname( aFileName );
ep->modTime = fname.GetModificationTime();
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* > if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
( aFileName, ep ) ).second == false ) ( aFileName, ep ) ).second == false )
@ -322,11 +322,6 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
return nullptr; return nullptr;
} }
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
m_CacheList.push_back( ep );
wxFileName fname( aFileName );
ep->modTime = fname.GetModificationTime();
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* > if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
( aFileName, ep ) ).second == false ) ( aFileName, ep ) ).second == false )
{ {

View File

@ -164,6 +164,8 @@ static const wxChar ShowPcbnewExportNetlist[] = wxT( "ShowPcbnewExportNetlist" )
static const wxChar Skip3DFileCache[] = wxT( "Skip3DFileCache" ); static const wxChar Skip3DFileCache[] = wxT( "Skip3DFileCache" );
static const wxChar Skip3DMemoryCache[] = wxT( "Skip3DMemoryCache" );
} // namespace KEYS } // namespace KEYS
@ -370,6 +372,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::Skip3DFileCache, configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::Skip3DFileCache,
&m_Skip3DFileCache, false ) ); &m_Skip3DFileCache, false ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::Skip3DMemoryCache,
&m_Skip3DMemoryCache, false ) );
wxConfigLoadSetups( &aCfg, configParams ); wxConfigLoadSetups( &aCfg, configParams );
dumpCfg( configParams ); dumpCfg( configParams );

View File

@ -175,6 +175,11 @@ public:
*/ */
bool m_Skip3DFileCache; bool m_Skip3DFileCache;
/**
* Skip reading/writing 3d model memory caches
*/
bool m_Skip3DMemoryCache;
private: private:
ADVANCED_CFG(); ADVANCED_CFG();