From 6b0176d5771b643f8a21d2eee69efcd35d6939de Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 18 Aug 2020 10:46:50 -0700 Subject: [PATCH] eeschema: lock model while updating scores The tree model adapter appears to have update issues when modifying the scores while it _might_ get updated. This moves the lock higher and removes the extraneous Freeze/Thaw call. Unfortunately, this only exposes an additional issue in the tool handler but this will hopefully be easier to debug. Fixes https://gitlab.com/kicad/code/kicad/issues/5206 --- common/lib_tree_model_adapter.cpp | 41 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 8783fcba9a..13fe26d134 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -188,38 +188,35 @@ void LIB_TREE_MODEL_ADAPTER::DoAddLibrary( wxString const& aNodeName, wxString c void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch ) { - m_tree.ResetScore(); - - for( auto& child: m_tree.m_Children ) - { - if( child->m_Pinned ) - child->m_Score *= 2; - } - - wxStringTokenizer tokenizer( aSearch ); - - while( tokenizer.HasMoreTokens() ) - { - const wxString term = tokenizer.GetNextToken().Lower(); - EDA_COMBINED_MATCHER matcher( term ); - - m_tree.UpdateScore( matcher ); - } - - m_tree.SortNodes(); - { wxWindowUpdateLocker updateLock( m_widget ); - Freeze(); + m_tree.ResetScore(); + + for( auto& child: m_tree.m_Children ) + { + if( child->m_Pinned ) + child->m_Score *= 2; + } + + wxStringTokenizer tokenizer( aSearch ); + + while( tokenizer.HasMoreTokens() ) + { + const wxString term = tokenizer.GetNextToken().Lower(); + EDA_COMBINED_MATCHER matcher( term ); + + m_tree.UpdateScore( matcher ); + } + // 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. // https://bugs.launchpad.net/kicad/+bug/1756255 m_widget->UnselectAll(); + m_tree.SortNodes(); Cleared(); - Thaw(); // This was fixed in wxWidgets 3.0.5 and 3.1.3. #if defined( __WXGTK__ ) && ( (wxVERSION_NUMBER < 030005 ) || \