Recently I submitted a patch to catch an error that occurred when loading a kicad_pcb containing invalid net IDs; I missed a couple spots. Here's another patch to fix the rest of them.
-- Chris
commit 98126b8cfba53c52119f809b094cbae266b41b75 Author: Chris Pavlina <[email protected]> Date: Thu Jun 11 19:44:14 2015 -0400 Correct remaining invalid net ID crashes diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 500e0c0..898551e 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -2310,9 +2310,17 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR ) break; case T_net: - pad->SetNetCode( getNetCode( parseInt( "net number" ) ) ); + if( ! pad->SetNetCode( getNetCode( parseInt( "net number" ) ), /* aNoAssert */ true ) ) + THROW_IO_ERROR( + wxString::Format( _( "invalid net ID in\nfile: <%s>\nline: %d\noffset: %d" ), + GetChars( CurSource() ), CurLineNumber(), CurOffset() ) + ); NeedSYMBOLorNUMBER(); - assert( FromUTF8() == m_board->FindNet( pad->GetNetCode() )->GetNetname() ); + if( FromUTF8() != m_board->FindNet( pad->GetNetCode() )->GetNetname() ) + THROW_IO_ERROR( + wxString::Format( _( "invalid net ID in\nfile: <%s>\nline: %d\noffset: %d" ), + GetChars( CurSource() ), CurLineNumber(), CurOffset() ) + ); NeedRIGHT(); break; @@ -2490,7 +2498,11 @@ VIA* PCB_PARSER::parseVIA() throw( IO_ERROR, PARSE_ERROR ) break; case T_net: - via->SetNetCode( getNetCode( parseInt( "net number" ) ) ); + if(! via->SetNetCode( getNetCode( parseInt( "net number" ) ), /* aNoAssert */ true)) + THROW_IO_ERROR( + wxString::Format( _( "invalid net ID in\nfile: <%s>\nline: %d\noffset: %d" ), + GetChars( CurSource() ), CurLineNumber(), CurOffset() ) + ); NeedRIGHT(); break; @@ -2550,7 +2562,11 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ) if( tmp < 0 ) tmp = 0; - zone->SetNetCode( tmp ); + if( ! zone->SetNetCode( tmp, /* aNoAssert */ true ) ) + THROW_IO_ERROR( + wxString::Format( _( "invalid net ID in\nfile: <%s>\nline: %d\noffset: %d" ), + GetChars( CurSource() ), CurLineNumber(), CurOffset() ) + ); NeedRIGHT(); break;
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

