Fix crash when parsing a PCB file with an invalid net code.
This commit is contained in:
parent
859435cabe
commit
097c73b8eb
|
@ -48,7 +48,7 @@ BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode )
|
bool BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode, bool aNoAssert )
|
||||||
{
|
{
|
||||||
// if aNetCode < 0 ( typically NETINFO_LIST::FORCE_ORPHANED )
|
// if aNetCode < 0 ( typically NETINFO_LIST::FORCE_ORPHANED )
|
||||||
// or no parent board,
|
// or no parent board,
|
||||||
|
@ -61,7 +61,9 @@ void BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode )
|
||||||
else
|
else
|
||||||
m_netinfo = &NETINFO_LIST::ORPHANED;
|
m_netinfo = &NETINFO_LIST::ORPHANED;
|
||||||
|
|
||||||
assert( m_netinfo );
|
if( !aNoAssert )
|
||||||
|
assert( m_netinfo );
|
||||||
|
return m_netinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -104,9 +104,11 @@ public:
|
||||||
* Function SetNetCode
|
* Function SetNetCode
|
||||||
* sets net using a net code.
|
* sets net using a net code.
|
||||||
* @param aNetCode is a net code for the new net. It has to exist in NETINFO_LIST held by BOARD.
|
* @param aNetCode is a net code for the new net. It has to exist in NETINFO_LIST held by BOARD.
|
||||||
|
* @param aNoAssert if true, do not assert that the net exists.
|
||||||
* Otherwise, item is assigned to the unconnected net.
|
* Otherwise, item is assigned to the unconnected net.
|
||||||
|
* @return true on success, false if the net did not exist
|
||||||
*/
|
*/
|
||||||
void SetNetCode( int aNetCode );
|
bool SetNetCode( int aNetCode, bool aNoAssert=false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetSubNet
|
* Function GetSubNet
|
||||||
|
|
|
@ -2408,7 +2408,11 @@ TRACK* PCB_PARSER::parseTRACK() throw( IO_ERROR, PARSE_ERROR )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_net:
|
case T_net:
|
||||||
track->SetNetCode( getNetCode( parseInt( "net number" ) ) );
|
if( ! track->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() )
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_tstamp:
|
case T_tstamp:
|
||||||
|
|
Loading…
Reference in New Issue