Readd freeze/thaw to the library tree update

This freeze/thaw is different than the update locker freeze/thaw,
and is needed to prevent crashes due to accessing invalid (already
freed) data on GTK.

Fixes https://gitlab.com/kicad/code/kicad/issues/5289
This commit is contained in:
Ian McInerney 2020-08-21 02:38:14 +01:00
parent c763d92275
commit 441243753d
1 changed files with 6 additions and 0 deletions

View File

@ -189,7 +189,12 @@ void LIB_TREE_MODEL_ADAPTER::DoAddLibrary( wxString const& aNodeName, wxString c
void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch )
{
{
// DO NOT REMOVE THE FREEZE/THAW. This freeze/thaw is a flag for this model adapter
// that tells it when it shouldn't trust any of the data in the model. When set, it will
// 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 );
Freeze();
m_tree.ResetScore();
@ -217,6 +222,7 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch )
m_tree.SortNodes();
Cleared();
Thaw();
// This was fixed in wxWidgets 3.0.5 and 3.1.3.
#if defined( __WXGTK__ ) && ( (wxVERSION_NUMBER < 030005 ) || \