Fix component selector segfault on MacOS
Fixes: lp:1666081 * https://bugs.launchpad.net/kicad/+bug/1666081
This commit is contained in:
parent
8bed8af03f
commit
35a8d78921
|
@ -146,8 +146,6 @@ void COMPONENT_TREE_SEARCH_CONTAINER::SetTree( TWO_COLUMN_TREE_LIST* aTree )
|
|||
m_tree->AppendColumn( _( "Description" ), 100, wxALIGN_LEFT, wxCOL_RESIZABLE );
|
||||
m_tree->SetRubberBandColumn( 1 );
|
||||
}
|
||||
|
||||
UpdateSearchTerm( wxEmptyString );
|
||||
}
|
||||
|
||||
|
||||
|
@ -506,11 +504,15 @@ void COMPONENT_TREE_SEARCH_CONTAINER::UpdateSearchTerm( const wxString& aSearch
|
|||
|
||||
if( first_match && ( !preselected_node || override_preselect ) )
|
||||
{
|
||||
// This is the wx call that pumps the event loop on some ports (namely
|
||||
// macOS). TODO: find a way to avoid that.
|
||||
m_tree->Select( first_match->TreeId );
|
||||
//m_tree->EnsureVisible( first_match->TreeId );
|
||||
}
|
||||
else if( preselected_node )
|
||||
{
|
||||
// This is the wx call that pumps the event loop on some ports (namely
|
||||
// macOS). TODO: find a way to avoid that.
|
||||
m_tree->Select( preselected_node->TreeId );
|
||||
//m_tree->EnsureVisible( preselected_node->TreeId );
|
||||
}
|
||||
|
|
|
@ -102,6 +102,10 @@ public:
|
|||
* scoring component at the top and selected. If a preselect node is set, this
|
||||
* is displayed. Does not take ownership of the tree.
|
||||
*
|
||||
* After calling SetTree(), UpdateSearchTerm( wxEmptyString ) should be
|
||||
* called. Note the warning with respsect to calling UpdateSearchTerm() in
|
||||
* dialog constructors.
|
||||
*
|
||||
* @param aTree that is to be modified on search updates.
|
||||
*/
|
||||
void SetTree( TWO_COLUMN_TREE_LIST* aTree );
|
||||
|
@ -109,6 +113,12 @@ public:
|
|||
/** Function UpdateSearchTerm
|
||||
* Update the search string provided by the user and narrow down the result list.
|
||||
*
|
||||
* XXX WARNING: Do not call this method in a dialog constructor until the
|
||||
* dialog has been otherwise fully initialized (i.e. this should be the last
|
||||
* thing called in the constructor). Some wx ports pump the event loop inside
|
||||
* this method, which can result in event handlers being called before things
|
||||
* they access are initialized.
|
||||
*
|
||||
* This string is a space-separated list of terms, each of which
|
||||
* is applied to the components list to narrow it down. Results are scored by
|
||||
* relevancy (e.g. exact match scores higher than prefix-match which in turn scores
|
||||
|
|
|
@ -44,7 +44,8 @@ static wxTreeListItem GetPrevSibling( const wxTreeListCtrl& tree, const wxTreeLi
|
|||
DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
||||
COMPONENT_TREE_SEARCH_CONTAINER* const aContainer,
|
||||
int aDeMorganConvert )
|
||||
: DIALOG_CHOOSE_COMPONENT_BASE( aParent, wxID_ANY, aTitle ), m_search_container( aContainer )
|
||||
: DIALOG_CHOOSE_COMPONENT_BASE( aParent, wxID_ANY, aTitle ), m_search_container( aContainer ),
|
||||
m_footprintPreviewPanel( nullptr )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_deMorganConvert = aDeMorganConvert >= 0 ? aDeMorganConvert : 0;
|
||||
|
@ -52,7 +53,6 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
|
|||
m_received_doubleclick_in_tree = false;
|
||||
m_search_container->SetTree( m_libraryComponentTree );
|
||||
m_componentView->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
m_footprintPreviewPanel = NULL;
|
||||
|
||||
// Initialize footprint preview through Kiway
|
||||
m_footprintPreviewPanel =
|
||||
|
@ -71,6 +71,10 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
|
|||
|
||||
Layout();
|
||||
Centre();
|
||||
|
||||
// Per warning in component_tree_search_container.h, this must be called
|
||||
// near the end of the constructor.
|
||||
m_search_container->UpdateSearchTerm( wxEmptyString );
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue