diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 2d41e40cdb..bb22210a68 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -145,12 +145,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.Children.size() ) m_widget->Collapse( wxDataViewItem( &*m_tree.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();