diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 1c17aaf3bf..83eaf6dc85 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -49,11 +49,11 @@ #include #include + extern int DiagErc[PINTYPE_COUNT][PINTYPE_COUNT]; extern int DefaultDiagErc[PINTYPE_COUNT][PINTYPE_COUNT]; - bool DIALOG_ERC::m_writeErcFile = false; // saved only for the current session bool DIALOG_ERC::m_TestSimilarLabels = true; // Save in project config bool DIALOG_ERC::m_diagErcTableInit = false; // saved only for the current session @@ -62,6 +62,7 @@ bool DIALOG_ERC::m_tstUniqueGlobalLabels = true; // saved only for the curren // Control identifiers for events #define ID_MATRIX_0 1800 + BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE ) EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PINTYPE_COUNT * PINTYPE_COUNT ) - 1, wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel ) @@ -80,6 +81,7 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : Centre(); } + DIALOG_ERC::~DIALOG_ERC() { m_TestSimilarLabels = m_cbTestSimilarLabels->GetValue(); @@ -157,6 +159,7 @@ void DIALOG_ERC::OnButtonCloseClick( wxCommandEvent& event ) Close(); } + void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event ) { Destroy(); @@ -438,7 +441,7 @@ void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event ) break; } - setDRCMatrixButtonState( butt, level); + setDRCMatrixButtonState( butt, level ); DiagErc[y][x] = DiagErc[x][y] = level; } @@ -492,8 +495,8 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) // Reset the connection type indicator objectsConnectedList->ResetConnectionsType(); - unsigned lastNet; - unsigned nextNet = lastNet = 0; + unsigned lastItemIdx; + unsigned nextItemIdx = lastItemIdx = 0; int MinConn = NOC; /* The netlist generated by SCH_EDIT_FRAME::BuildNetListBase is sorted @@ -505,17 +508,24 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) * pass. */ - for( unsigned net = 0; net < objectsConnectedList->size(); net++ ) + for( unsigned itemIdx = 0; itemIdx < objectsConnectedList->size(); itemIdx++ ) { - if( objectsConnectedList->GetItemNet( lastNet ) != - objectsConnectedList->GetItemNet( net ) ) + auto item = objectsConnectedList->GetItem( itemIdx ); + auto lastItem = objectsConnectedList->GetItem( lastItemIdx ); + + auto lastNet = lastItem->GetNet(); + auto net = item->GetNet(); + + wxASSERT_MSG( lastNet <= net, wxT( "Netlist not correctly ordered" ) ); + + if( lastNet != net ) { // New net found: - MinConn = NOC; - nextNet = net; + MinConn = NOC; + nextItemIdx = itemIdx; } - switch( objectsConnectedList->GetItemType( net ) ) + switch( item->m_Type ) { // These items do not create erc problems case NET_ITEM_UNSPECIFIED: @@ -535,11 +545,11 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) // ERC problems when pin sheets do not match hierarchical labels. // Each pin sheet must match a hierarchical label // Each hierarchical label must match a pin sheet - objectsConnectedList->TestforNonOrphanLabel( net, nextNet ); + objectsConnectedList->TestforNonOrphanLabel( itemIdx, nextItemIdx ); break; case NET_GLOBLABEL: if( m_tstUniqueGlobalLabels ) - objectsConnectedList->TestforNonOrphanLabel( net, nextNet ); + objectsConnectedList->TestforNonOrphanLabel( itemIdx, nextItemIdx ); break; case NET_NOCONNECT: @@ -547,19 +557,19 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) // ERC problems when a noconnect symbol is connected to more than one pin. MinConn = NET_NC; - if( objectsConnectedList->CountPinsInNet( nextNet ) > 1 ) - Diagnose( objectsConnectedList->GetItem( net ), NULL, MinConn, UNC ); + if( objectsConnectedList->CountPinsInNet( nextItemIdx ) > 1 ) + Diagnose( item, NULL, MinConn, UNC ); break; case NET_PIN: // Look for ERC problems between pins: - TestOthersItems( objectsConnectedList.get(), net, nextNet, &MinConn ); + TestOthersItems( objectsConnectedList.get(), itemIdx, nextItemIdx, &MinConn ); break; } - lastNet = net; + lastItemIdx = itemIdx; } // Test similar labels (i;e. labels which are identical when