Use CallAfter instead of Idle event hack for drc dialog item selection

This commit is contained in:
Marek Roszko 2024-02-04 12:37:48 -05:00
parent cab351d249
commit 5d0abd3b01
2 changed files with 5 additions and 26 deletions

View File

@ -72,7 +72,6 @@ DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
m_markersTreeModel( nullptr ),
m_unconnectedTreeModel( nullptr ),
m_fpWarningsTreeModel( nullptr ),
m_centerMarkerOnIdle( nullptr ),
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING )
{
SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it
@ -398,15 +397,6 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent )
return;
}
if( m_centerMarkerOnIdle )
{
// we already came from a cross-probe of the marker in the document; don't go
// around in circles
aEvent.Skip();
return;
}
std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
if( rc_item->GetErrorCode() == DRCE_UNRESOLVED_VARIABLE
@ -1006,22 +996,15 @@ void DIALOG_DRC::SelectMarker( const PCB_MARKER* aMarker )
m_Notebook->SetSelection( 0 );
m_markersTreeModel->SelectMarker( aMarker );
// wxWidgets on some platforms fails to correctly ensure that a selected item is
// visible, so we have to do it in a separate idle event.
m_centerMarkerOnIdle = aMarker;
Bind( wxEVT_IDLE, &DIALOG_DRC::centerMarkerIdleHandler, this );
CallAfter(
[=]
{
m_markersTreeModel->CenterMarker( aMarker );
} );
}
}
void DIALOG_DRC::centerMarkerIdleHandler( wxIdleEvent& aEvent )
{
m_markersTreeModel->CenterMarker( m_centerMarkerOnIdle );
m_centerMarkerOnIdle = nullptr;
Unbind( wxEVT_IDLE, &DIALOG_DRC::centerMarkerIdleHandler, this );
}
void DIALOG_DRC::ExcludeMarker()
{
if( !m_Notebook->IsShown() || m_Notebook->GetSelection() != 0 )

View File

@ -98,8 +98,6 @@ private:
void OnChangingNotebookPage( wxNotebookEvent& aEvent ) override;
void centerMarkerIdleHandler( wxIdleEvent& aEvent );
void deleteAllMarkers( bool aIncludeExclusions );
void refreshEditor();
@ -128,8 +126,6 @@ private:
RC_TREE_MODEL* m_unconnectedTreeModel; // wx reference-counted ptr
RC_TREE_MODEL* m_fpWarningsTreeModel; // wx reference-counted ptr
const PCB_MARKER* m_centerMarkerOnIdle;
int m_severities; // A mask of SEVERITY flags
};