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

View File

@ -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();