Library Editor: fixed a crash after a library is removed

This commit is contained in:
Maciej Suminski 2017-11-14 15:24:50 +01:00
parent 6400e31d5b
commit b229286313
1 changed files with 4 additions and 5 deletions

View File

@ -49,10 +49,7 @@ void LIB_MANAGER_ADAPTER::RemoveLibrary( const wxString& aLibNickname )
[&] ( std::unique_ptr<CMP_TREE_NODE>& node ) { return node->Name == aLibNickname; } ); [&] ( std::unique_ptr<CMP_TREE_NODE>& node ) { return node->Name == aLibNickname; } );
if( it != m_tree.Children.end() ) if( it != m_tree.Children.end() )
{ deleteLibrary( it );
ItemDeleted( wxDataViewItem( nullptr ), ToItem( it->get() ) );
m_tree.Children.erase( it );
}
} }
@ -185,7 +182,9 @@ void LIB_MANAGER_ADAPTER::updateLibrary( CMP_TREE_NODE_LIB& aLibNode )
CMP_TREE_NODE::PTR_VECTOR::iterator LIB_MANAGER_ADAPTER::deleteLibrary( CMP_TREE_NODE::PTR_VECTOR::iterator LIB_MANAGER_ADAPTER::deleteLibrary(
CMP_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt ) CMP_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt )
{ {
m_libHashes.erase( aLibNodeIt->get()->Name ); CMP_TREE_NODE* node = aLibNodeIt->get();
ItemDeleted( wxDataViewItem( nullptr ), ToItem( node ) );
m_libHashes.erase( node->Name );
auto it = m_tree.Children.erase( aLibNodeIt ); auto it = m_tree.Children.erase( aLibNodeIt );
return it; return it;
} }