Fix access into empty container.
Fixes https://gitlab.com/kicad/code/kicad/issues/6840
This commit is contained in:
parent
a9ff98bccc
commit
359c29639f
|
@ -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<LIB_TREE_NODE>& 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<LIB_TREE_NODE>& 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<LIB_TREE_NODE>& 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<LIB_TREE_NODE>& child: m_Children )
|
||||
child->UpdateScore( aMatcher );
|
||||
}
|
||||
|
||||
|
|
|
@ -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<LIB_TREE_NODE>& child: m_tree.m_Children )
|
||||
{
|
||||
if( child->m_Pinned )
|
||||
child->m_Score *= 2;
|
||||
|
|
Loading…
Reference in New Issue