DRC Control: Clear pointer to MARKER after it has been centered

Also, added asserts to verify SelectMarker and CenterMarker actually
do select one.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9344
This commit is contained in:
Roberto Fernandez Bautista 2021-10-10 16:12:12 +01:00
parent 48f9dfa988
commit 0fa8e1f311
2 changed files with 8 additions and 2 deletions

View File

@ -601,9 +601,11 @@ void RC_TREE_MODEL::SelectMarker( const MARKER_BASE* aMarker )
if( candidate->m_RcItem->GetParent() == aMarker ) if( candidate->m_RcItem->GetParent() == aMarker )
{ {
m_view->Select( ToItem( candidate ) ); m_view->Select( ToItem( candidate ) );
break; return;
} }
} }
wxFAIL_MSG( "Unable to select marker" );
} }
@ -614,9 +616,11 @@ void RC_TREE_MODEL::CenterMarker( const MARKER_BASE* aMarker )
if( candidate->m_RcItem->GetParent() == aMarker ) if( candidate->m_RcItem->GetParent() == aMarker )
{ {
m_view->EnsureVisible( ToItem( candidate ) ); m_view->EnsureVisible( ToItem( candidate ) );
break; return;
} }
} }
wxFAIL_MSG( "Unable to center marker" );
} }

View File

@ -60,6 +60,7 @@ DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
m_unconnectedTreeModel( nullptr ), m_unconnectedTreeModel( nullptr ),
m_footprintWarningsProvider( nullptr ), m_footprintWarningsProvider( nullptr ),
m_footprintWarningsTreeModel( nullptr ), m_footprintWarningsTreeModel( nullptr ),
m_centerMarkerOnIdle(nullptr),
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ) m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING )
{ {
SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it
@ -769,6 +770,7 @@ void DIALOG_DRC::SelectMarker( const PCB_MARKER* aMarker )
void DIALOG_DRC::centerMarkerIdleHandler( wxIdleEvent& aEvent ) void DIALOG_DRC::centerMarkerIdleHandler( wxIdleEvent& aEvent )
{ {
m_markersTreeModel->CenterMarker( m_centerMarkerOnIdle ); m_markersTreeModel->CenterMarker( m_centerMarkerOnIdle );
m_centerMarkerOnIdle = nullptr;
Unbind( wxEVT_IDLE, &DIALOG_DRC::centerMarkerIdleHandler, this ); Unbind( wxEVT_IDLE, &DIALOG_DRC::centerMarkerIdleHandler, this );
} }