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
This commit is contained in:
Seth Hillbrand 2020-10-29 15:44:32 -07:00
parent fc6fc88219
commit 3bd080b64e
1 changed files with 1 additions and 1 deletions

View File

@ -195,7 +195,6 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch )
// not return invalid data to the UI, since this invalid data can cause crashes. // 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. // This is different than the update locker, which locks the UI aspects only.
wxWindowUpdateLocker updateLock( m_widget ); wxWindowUpdateLocker updateLock( m_widget );
BeforeReset();
// Even with the updateLock, wxWidgets sometimes ties its knickers in // Even with the updateLock, wxWidgets sometimes ties its knickers in
// a knot when trying to run a wxdataview_selection_changed_callback() // a knot when trying to run a wxdataview_selection_changed_callback()
@ -203,6 +202,7 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch )
// https://bugs.launchpad.net/kicad/+bug/1756255 // https://bugs.launchpad.net/kicad/+bug/1756255
m_widget->UnselectAll(); m_widget->UnselectAll();
Freeze(); Freeze();
BeforeReset();
m_tree.ResetScore(); m_tree.ResetScore();