Libedit: fix crashes when no active libary selected (happens when creating a new component)

This commit is contained in:
jean-pierre charras 2011-03-30 12:51:51 +02:00
parent 67f70fe079
commit 1f087b2f55
2 changed files with 13 additions and 6 deletions

View File

@ -304,8 +304,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event )
if( aliasname.IsEmpty() )
return;
if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND
|| library->FindEntry( aliasname ) != NULL )
if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND )
{
wxString msg;
msg.Printf( _( "Alias or component name <%s> already in use." ),
GetChars( aliasname ) );
DisplayError( this, msg );
return;
}
if( library && library->FindEntry( aliasname ) != NULL )
{
wxString msg;
msg.Printf( _( "Alias or component name <%s> already exists in library <%s>." ),

View File

@ -69,7 +69,7 @@ void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField )
wxString msg;
// Test the current library for name conflicts.
if( m_library->FindEntry( text ) != NULL )
if( m_library && m_library->FindEntry( text ) != NULL )
{
msg.Printf( _( "The name <%s> conflicts with an existing entry in the component \
library <%s>.\n\nDo you wish to replace the current component in library with this one?" ),
@ -88,8 +88,7 @@ library <%s>.\n\nDo you wish to replace the current component in library with th
{
msg.Printf( _( "The current component already has an alias named <%s>.\n\nDo you \
wish to remove this alias from the component?" ),
GetChars( text ),
GetChars( m_library->GetName() ) );
GetChars( text ) );
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
@ -102,7 +101,7 @@ wish to remove this alias from the component?" ),
parent->SetName( text );
// Test the library for any conflicts with the any aliases in the current component.
if( parent->GetAliasCount() > 1 && m_library->Conflicts( parent ) )
if( parent->GetAliasCount() > 1 && m_library && m_library->Conflicts( parent ) )
{
msg.Printf( _( "The new component contains alias names that conflict with entries \
in the component library <%s>.\n\nDo you wish to remove all of the conflicting aliases from \