Add try/catch block around writing a new library.
Fixes: lp:1825203
* https://bugs.launchpad.net/kicad/+bug/1825203
(cherry picked from commit 2bcf38d2b6
)
This commit is contained in:
parent
583d416640
commit
6e8979d8d8
|
@ -645,14 +645,15 @@ bool LIB_MANAGER::addLibrary( const wxString& aFilePath, bool aCreate, SYMBOL_LI
|
|||
|
||||
if( aCreate )
|
||||
{
|
||||
// CreateSymbolLib() fails if the file exists
|
||||
if( wxFileName::Exists( aFilePath ) )
|
||||
try
|
||||
{
|
||||
if( !wxRemoveFile( aFilePath ) )
|
||||
return false;
|
||||
aTable->CreateSymbolLib( libName );
|
||||
}
|
||||
catch( const IO_ERROR& e )
|
||||
{
|
||||
aTable->RemoveRow( libRow );
|
||||
return false;
|
||||
}
|
||||
|
||||
aTable->CreateSymbolLib( libName );
|
||||
}
|
||||
|
||||
m_frame.SyncLibraries( false );
|
||||
|
@ -682,10 +683,12 @@ std::set<LIB_PART*> LIB_MANAGER::getOriginalParts( const wxString& aLibrary )
|
|||
LIB_ALIAS* alias = symTable()->LoadSymbol( aLibrary, aliasName );
|
||||
parts.insert( alias->GetPart() );
|
||||
}
|
||||
} catch( const IO_ERROR& e )
|
||||
}
|
||||
catch( const IO_ERROR& e )
|
||||
{
|
||||
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot enumerate "
|
||||
"library \"%s\"" ), aLibrary ), e.What() );
|
||||
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot enumerate library \"%s\"" ),
|
||||
aLibrary ),
|
||||
e.What() );
|
||||
}
|
||||
|
||||
return parts;
|
||||
|
|
|
@ -414,6 +414,24 @@ public:
|
|||
*/
|
||||
bool InsertRow( LIB_TABLE_ROW* aRow, bool doReplace = false );
|
||||
|
||||
/**
|
||||
* Removes a row from the table.
|
||||
* @param aRow is the row to remove
|
||||
* @return true if the row was found (and removed)
|
||||
*/
|
||||
bool RemoveRow( LIB_TABLE_ROW* aRow )
|
||||
{
|
||||
for( auto iter = rows.begin(); iter != rows.end(); ++iter )
|
||||
{
|
||||
if( *iter == *aRow )
|
||||
{
|
||||
rows.erase( iter, iter + 1 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a #LIB_TABLE_ROW pointer if \a aURI is found in this table or in any chained
|
||||
* fallBack table fragments, else NULL.
|
||||
|
|
Loading…
Reference in New Issue