Fix schematic cache library broken by schematic I/O plugin changes.
Check for existence of cache library when before attempting to rebuild the cache. Create a new cache library object if no cache library was loaded. Add missing buffering and cache properties to LIB_PART::FindAlias() to prevent the plugin from reloading the cache library that may not exist. Add method to find library by full path and file name. Revert the check for a symbol in the cache library remove from last patch. Add checks for plugin cache file name validity and existence of a the file before attempting to verify the file modification time to prevent wxWidgets from raising an assertion in debug builds. Clear modified flag when saving buffered and/or cached library.
This commit is contained in:
parent
2a793cc22c
commit
175d68fbb1
|
@ -97,6 +97,7 @@ void PART_LIB::Save( bool aSaveDocFile )
|
|||
}
|
||||
|
||||
m_plugin->SaveLibrary( fileName.GetFullPath(), props.get() );
|
||||
isModified = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -165,7 +166,20 @@ void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames )
|
|||
|
||||
LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName )
|
||||
{
|
||||
return m_plugin->LoadSymbol( fileName.GetFullPath(), aName );
|
||||
std::unique_ptr< PROPERTIES > props;
|
||||
|
||||
if( isCache || m_buffering )
|
||||
{
|
||||
props.reset( new PROPERTIES );
|
||||
|
||||
if( isCache )
|
||||
(*props.get())[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
||||
|
||||
if( m_buffering )
|
||||
(*props.get())[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
|
||||
}
|
||||
|
||||
return m_plugin->LoadSymbol( fileName.GetFullPath(), aName, props.get() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,6 +386,18 @@ PART_LIB* PART_LIBS::FindLibrary( const wxString& aName )
|
|||
}
|
||||
|
||||
|
||||
PART_LIB* PART_LIBS::FindLibraryByFullFileName( const wxString& aFullFileName )
|
||||
{
|
||||
for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
|
||||
{
|
||||
if( it->GetFullFileName() == aFullFileName )
|
||||
return &*it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
wxArrayString PART_LIBS::GetLibraryNames( bool aSorted )
|
||||
{
|
||||
wxArrayString cacheNames;
|
||||
|
|
|
@ -258,6 +258,8 @@ public:
|
|||
*/
|
||||
PART_LIB* FindLibrary( const wxString& aName );
|
||||
|
||||
PART_LIB* FindLibraryByFullFileName( const wxString& aFullFileName );
|
||||
|
||||
/**
|
||||
* Function GetLibraryNames
|
||||
* returns the list of part library file names without path and extension.
|
||||
|
|
|
@ -61,8 +61,13 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
|
|||
wxString msg;
|
||||
SCH_SCREENS screens;
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
PART_LIB* cacheLib = libs->FindLibraryByFullFileName( aFileName );
|
||||
|
||||
std::unique_ptr<PART_LIB> cacheLib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
|
||||
if( !cacheLib )
|
||||
{
|
||||
cacheLib = new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName );
|
||||
libs->push_back( cacheLib );
|
||||
}
|
||||
|
||||
cacheLib->SetCache();
|
||||
cacheLib->EnableBuffering();
|
||||
|
@ -79,24 +84,28 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
|
|||
continue;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
LIB_PART* part = NULL;
|
||||
|
||||
try
|
||||
if( !cacheLib->FindAlias( component->GetLibId().GetLibItemName() ) )
|
||||
{
|
||||
part = libs->FindLibPart( component->GetLibId() );
|
||||
LIB_PART* part = NULL;
|
||||
|
||||
if( part )
|
||||
try
|
||||
{
|
||||
// AddPart() does first clone the part before adding.
|
||||
cacheLib->AddPart( part );
|
||||
part = libs->FindLibPart( component->GetLibId() );
|
||||
|
||||
if( part )
|
||||
{
|
||||
// AddPart() does first clone the part before adding.
|
||||
cacheLib->AddPart( part );
|
||||
}
|
||||
}
|
||||
catch( ... /* IO_ERROR ioe */ )
|
||||
{
|
||||
msg.Printf( _( "Failed to add symbol %s to library file '%s'" ),
|
||||
wxString( component->GetLibId().GetLibItemName() ), aFileName );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch( ... /* IO_ERROR ioe */ )
|
||||
{
|
||||
msg.Printf( _( "Failed to add symbol %s to library file '%s'" ),
|
||||
wxString( component->GetLibId().GetLibItemName() ), aFileName );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2060,7 +2060,10 @@ bool SCH_LEGACY_PLUGIN_CACHE::IsFile( const wxString& aFullPathAndFileName ) con
|
|||
|
||||
bool SCH_LEGACY_PLUGIN_CACHE::IsFileChanged() const
|
||||
{
|
||||
return m_libFileName.GetModificationTime() != m_fileModTime;
|
||||
if( m_fileModTime.IsValid() && m_libFileName.IsOk() && m_libFileName.FileExists() )
|
||||
return m_libFileName.GetModificationTime() != m_fileModTime;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue