Commit 1f087b2f authored by jean-pierre charras's avatar jean-pierre charras

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

parent 67f70fe0
...@@ -304,8 +304,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event ) ...@@ -304,8 +304,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event )
if( aliasname.IsEmpty() ) if( aliasname.IsEmpty() )
return; return;
if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND )
|| library->FindEntry( aliasname ) != NULL ) {
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; wxString msg;
msg.Printf( _( "Alias or component name <%s> already exists in library <%s>." ), msg.Printf( _( "Alias or component name <%s> already exists in library <%s>." ),
......
...@@ -69,7 +69,7 @@ void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField ) ...@@ -69,7 +69,7 @@ void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField )
wxString msg; wxString msg;
// Test the current library for name conflicts. // 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 \ 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?" ), 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 ...@@ -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 \ msg.Printf( _( "The current component already has an alias named <%s>.\n\nDo you \
wish to remove this alias from the component?" ), wish to remove this alias from the component?" ),
GetChars( text ), GetChars( text ) );
GetChars( m_library->GetName() ) );
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this ); int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
...@@ -102,7 +101,7 @@ wish to remove this alias from the component?" ), ...@@ -102,7 +101,7 @@ wish to remove this alias from the component?" ),
parent->SetName( text ); parent->SetName( text );
// Test the library for any conflicts with the any aliases in the current component. // 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 \ 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 \ in the component library <%s>.\n\nDo you wish to remove all of the conflicting aliases from \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment