diff --git a/common/lib_tree_model.cpp b/common/lib_tree_model.cpp index 96229801ac..4bc8f155bd 100644 --- a/common/lib_tree_model.cpp +++ b/common/lib_tree_model.cpp @@ -52,7 +52,7 @@ static int matchPosScore(int aPosition, int aMaximum) void LIB_TREE_NODE::ResetScore() { - for( auto& child: m_Children ) + for( std::unique_ptr& child: m_Children ) child->ResetScore(); m_Score = kLowestDefaultScore; @@ -72,8 +72,8 @@ void LIB_TREE_NODE::AssignIntrinsicRanks( bool presorted ) } else { - for( auto const& node: m_Children ) - sort_buf.push_back( &*node ); + for( std::unique_ptr& child: m_Children ) + sort_buf.push_back( child.get() ); std::sort( sort_buf.begin(), sort_buf.end(), []( LIB_TREE_NODE* a, LIB_TREE_NODE* b ) -> bool @@ -289,7 +289,7 @@ void LIB_TREE_NODE_LIB::UpdateScore( EDA_COMBINED_MATCHER& aMatcher ) if( m_Children.size() ) { - for( auto& child: m_Children ) + for( std::unique_ptr& child: m_Children ) { child->UpdateScore( aMatcher ); m_Score = std::max( m_Score, child->m_Score ); @@ -333,7 +333,7 @@ LIB_TREE_NODE_LIB& LIB_TREE_NODE_ROOT::AddLib( wxString const& aName, wxString c void LIB_TREE_NODE_ROOT::UpdateScore( EDA_COMBINED_MATCHER& aMatcher ) { - for( auto& child: m_Children ) + for( std::unique_ptr& child: m_Children ) child->UpdateScore( aMatcher ); } diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index b2e62fe751..7d31bf76d1 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -196,12 +196,11 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch ) // is called, GetParent() will return nullptr. While this works for some calls, it // segfaults when we have our first library expanded. // The tree will be expanded again below when we get our matches - if( !aSearch.IsNull() ) + if( !aSearch.IsNull() && m_tree.m_Children.size() ) m_widget->Collapse( wxDataViewItem( &*m_tree.m_Children[0] ) ); - // Even with the updateLock, wxWidgets sometimes ties its knickers in - // a knot when trying to run a wxdataview_selection_changed_callback() - // on a row that has been deleted. + // Even with the updateLock, wxWidgets sometimes ties its knickers in a knot trying to + // run a wxdataview_selection_changed_callback() on a row that has been deleted. // https://bugs.launchpad.net/kicad/+bug/1756255 m_widget->UnselectAll(); @@ -214,7 +213,7 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch ) m_tree.ResetScore(); - for( auto& child: m_tree.m_Children ) + for( std::unique_ptr& child: m_tree.m_Children ) { if( child->m_Pinned ) child->m_Score *= 2;