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 );
|
libTable->InsertRow( libRow );
|
||||||
|
|
||||||
if( aCreate )
|
if( aCreate )
|
||||||
|
{
|
||||||
|
// CreateSymbolLib() fails if the file exists
|
||||||
|
if( wxFileName::Exists( aFilePath ) )
|
||||||
|
{
|
||||||
|
if( !wxRemoveFile( aFilePath ) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
libTable->CreateSymbolLib( libName );
|
libTable->CreateSymbolLib( libName );
|
||||||
|
}
|
||||||
|
|
||||||
getAdapter()->AddLibrary( libName );
|
getAdapter()->AddLibrary( libName );
|
||||||
|
|
||||||
|
|
|
@ -1510,6 +1510,7 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
||||||
{
|
{
|
||||||
wxFileName fileName = getLibraryFileName( !aCreateNew );
|
wxFileName fileName = getLibraryFileName( !aCreateNew );
|
||||||
wxString libName = fileName.GetName();
|
wxString libName = fileName.GetName();
|
||||||
|
bool res = false;
|
||||||
|
|
||||||
if( libName.IsEmpty() )
|
if( libName.IsEmpty() )
|
||||||
return false;
|
return false;
|
||||||
|
@ -1521,12 +1522,22 @@ bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_libMgr->AddLibrary( fileName.GetFullPath() );
|
|
||||||
|
|
||||||
if( aCreateNew )
|
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