Library Editor: fixed a crash when creating a new library with existing file
This commit is contained in:
parent
8b0041bf9a
commit
aaabf8ab78
|
@ -541,7 +541,16 @@ bool LIB_MANAGER::addLibrary( const wxString& aFilePath, bool aCreate )
|
|||
libTable->InsertRow( libRow );
|
||||
|
||||
if( aCreate )
|
||||
{
|
||||
// CreateSymbolLib() fails if the file exists
|
||||
if( wxFileName::Exists( aFilePath ) )
|
||||
{
|
||||
if( !wxRemoveFile( aFilePath ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
libTable->CreateSymbolLib( libName );
|
||||
}
|
||||
|
||||
getAdapter()->AddLibrary( libName );
|
||||
|
||||
|
|
|
@ -1510,6 +1510,7 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
|||
{
|
||||
wxFileName fileName = getLibraryFileName( !aCreateNew );
|
||||
wxString libName = fileName.GetName();
|
||||
bool res = false;
|
||||
|
||||
if( libName.IsEmpty() )
|
||||
return false;
|
||||
|
@ -1521,12 +1522,22 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
|||
return false;
|
||||
}
|
||||
|
||||
m_libMgr->AddLibrary( fileName.GetFullPath() );
|
||||
|
||||
if( aCreateNew )
|
||||
Prj().SchSymbolLibTable()->CreateSymbolLib( libName );
|
||||
{
|
||||
res = m_libMgr->CreateLibrary( fileName.GetFullPath() );
|
||||
|
||||
return true;
|
||||
if( !res )
|
||||
DisplayError( this, _( "Could not create the library file. Check write permission." ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
res = m_libMgr->AddLibrary( fileName.GetFullPath() );
|
||||
|
||||
if( !res )
|
||||
DisplayError( this, _( "Could not open the library file." ) );
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue