Markers provider is no longer responsible for all markers.

Unconnected items and schematic partity violations are also now
represented by markers, so the ERC/DRC window itself needs to do
the deep-delete.

Fixes https://gitlab.com/kicad/code/kicad/issues/12182
This commit is contained in:
Jeff Young 2022-08-08 22:00:37 +01:00
parent 73402d733e
commit a11f48ef10
10 changed files with 13 additions and 43 deletions

View File

@ -539,8 +539,8 @@ void RC_TREE_MODEL::DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, boo
ItemDeleted( parentItem, markerItem );
}
// Only deep delete the current item here; others will be done through the
// DeleteAllItems() call below, which is more efficient.
// Only deep delete the current item here; others will be done by the caller, which
// can more efficiently delete all markers on the board.
m_rcItemsProvider->DeleteItem( i, aDeep && aCurrentOnly );
if( lastGood > i )
@ -555,9 +555,6 @@ void RC_TREE_MODEL::DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, boo
for( RC_TREE_NODE* item : to_delete )
delete( item );
if( !aCurrentOnly && aDeep )
m_rcItemsProvider->DeleteAllItems( aIncludeExclusions, aDeep );
if( m_view )
m_view->Thaw();
}

View File

@ -908,7 +908,10 @@ void DIALOG_ERC::deleteAllMarkers( bool aIncludeExclusions )
// Clear current selection list to avoid selection of deleted items
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
m_markerTreeModel->DeleteItems( false, aIncludeExclusions, true );
m_markerTreeModel->DeleteItems( false, aIncludeExclusions, false );
SCH_SCREENS screens( m_parent->Schematic().Root() );
screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC, aIncludeExclusions );
}

View File

@ -379,13 +379,3 @@ void SHEETLIST_ERC_ITEMS_PROVIDER::DeleteItem( int aIndex, bool aDeep )
}
void SHEETLIST_ERC_ITEMS_PROVIDER::DeleteAllItems( bool aIncludeExclusions, bool aDeep )
{
// Filtered list was already handled through DeleteItem() by the tree control
if( aDeep )
{
SCH_SCREENS screens( m_schematic->Root() );
screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC, aIncludeExclusions );
}
}

View File

@ -204,8 +204,6 @@ public:
void DeleteItem( int aIndex, bool aDeep ) override;
void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override;
private:
void visitMarkers( std::function<void( SCH_MARKER* )> aVisitor ) const;

View File

@ -61,8 +61,6 @@ public:
*/
virtual void DeleteItem( int aIndex, bool aDeep ) = 0;
virtual void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) = 0;
virtual ~RC_ITEMS_PROVIDER() { }
};

View File

@ -92,7 +92,6 @@ public:
return m_sourceVector->at( aIndex );
}
void DeleteItem( int aIndex, bool aDeep ) override
{
if( aDeep )
@ -102,14 +101,6 @@ public:
}
}
void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override
{
if( aDeep )
{
m_sourceVector->clear();
}
}
private:
std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
};

View File

@ -267,8 +267,6 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
m_frame->RecordDRCExclusions();
deleteAllMarkers( true );
m_unconnectedTreeModel->DeleteItems( false, true, true );
m_footprintWarningsTreeModel->DeleteItems( false, true, true );
std::vector<std::reference_wrapper<RC_ITEM>> violations = DRC_ITEM::GetItemsWithSeverities();
m_ignoredList->DeleteAllItems();
@ -998,7 +996,11 @@ void DIALOG_DRC::deleteAllMarkers( bool aIncludeExclusions )
// Clear current selection list to avoid selection of deleted items
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
m_markersTreeModel->DeleteItems( false, aIncludeExclusions, true );
m_markersTreeModel->DeleteItems( false, aIncludeExclusions, false );
m_unconnectedTreeModel->DeleteItems( false, aIncludeExclusions, false );
m_footprintWarningsTreeModel->DeleteItems( false, aIncludeExclusions, false );
m_frame->GetBoard()->DeleteMARKERs( true, aIncludeExclusions );
}

View File

@ -354,7 +354,8 @@ void DIALOG_FOOTPRINT_CHECKER::deleteAllMarkers()
// Clear current selection list to avoid selection of deleted items
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
m_markersTreeModel->DeleteItems( false, true, true );
m_markersTreeModel->DeleteItems( false, true, false );
m_frame->GetBoard()->DeleteMARKERs( true, true );
}

View File

@ -484,11 +484,3 @@ void DRC_ITEMS_PROVIDER::DeleteItem( int aIndex, bool aDeep )
m_board->Delete( marker );
}
void DRC_ITEMS_PROVIDER::DeleteAllItems( bool aIncludeExclusions, bool aDeep )
{
// Filtered list was already handled through DeleteItem() by the tree control
if( aDeep )
m_board->DeleteMARKERs( true, aIncludeExclusions );
}

View File

@ -231,8 +231,6 @@ public:
void DeleteItem( int aIndex, bool aDeep ) override;
void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override;
private:
BOARD* m_board;
MARKER_BASE::TYPEMARKER m_markerType;