Fix crash when renaming a component in symbol library editor

COMPONENT_TREE::STATE used wxDataViewItem to store the selection, but it
will point to a deleted object if the selection was removed. Switched to
storing the selection using LIB_ID as it is much safer to use.
This commit is contained in:
Maciej Suminski 2017-12-11 11:22:24 +01:00
parent f19aed9d5c
commit aedf24d944
2 changed files with 4 additions and 7 deletions

View File

@ -195,7 +195,7 @@ COMPONENT_TREE::STATE COMPONENT_TREE::getState() const
state.expanded.push_back( item );
}
state.selection = m_tree_ctrl->GetSelection();
state.selection = GetSelectedLibId();
return state;
}
@ -208,11 +208,8 @@ void COMPONENT_TREE::setState( const STATE& aState )
for( const auto& item : aState.expanded )
m_tree_ctrl->Expand( item );
if( aState.selection.IsOk() )
{
m_tree_ctrl->ExpandAncestors( aState.selection );
m_tree_ctrl->SetCurrentItem( aState.selection );
}
if( aState.selection.IsValid() )
SelectLibId( aState.selection );
}

View File

@ -117,7 +117,7 @@ protected:
std::vector<wxDataViewItem> expanded;
///> Current selection, might be not valid if nothing was selected
wxDataViewItem selection;
LIB_ID selection;
};
/**