diff --git a/eeschema/widgets/component_tree.cpp b/eeschema/widgets/component_tree.cpp index c24559744b..7e2119d312 100644 --- a/eeschema/widgets/component_tree.cpp +++ b/eeschema/widgets/component_tree.cpp @@ -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 ); } diff --git a/eeschema/widgets/component_tree.h b/eeschema/widgets/component_tree.h index 2593c3a40e..d4fcd23f32 100644 --- a/eeschema/widgets/component_tree.h +++ b/eeschema/widgets/component_tree.h @@ -117,7 +117,7 @@ protected: std::vector expanded; ///> Current selection, might be not valid if nothing was selected - wxDataViewItem selection; + LIB_ID selection; }; /**