From 1f6ff4a51958a174d48726513a33842d3e21d854 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 24 Dec 2020 19:42:41 +0000 Subject: [PATCH] Fix access into empty container. Fixes https://gitlab.com/kicad/code/kicad/issues/6840 (cherry picked from commit 359c29639fd6e4c6f17d6d2b167d840821d31ab6) --- common/lib_tree_model_adapter.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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();