From 73bf4cbce7446d0a5ec30e9124427813703bebeb Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 29 Oct 2020 15:44:32 -0700 Subject: [PATCH] Unselect and freeze before starting reset In some cases, the BeforeReset() will cause an iteration over the tree elements. If we have deleted an element before doing this, we risk a corruption/crash. Fixes https://gitlab.com/kicad/code/kicad/issues/6192 (cherry picked from commit 3bd080b64e05c7f961f15549a9b8ebeeac64b8c8) --- common/lib_tree_model_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 6b8d8537e4..aa036ee2ff 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -144,7 +144,6 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch ) // not return invalid data to the UI, since this invalid data can cause crashes. // This is different than the update locker, which locks the UI aspects only. wxWindowUpdateLocker updateLock( m_widget ); - BeforeReset(); // Even with the updateLock, wxWidgets sometimes ties its knickers in // a knot when trying to run a wxdataview_selection_changed_callback() @@ -152,6 +151,7 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch ) // https://bugs.launchpad.net/kicad/+bug/1756255 m_widget->UnselectAll(); Freeze(); + BeforeReset(); m_tree.ResetScore();