Commit c7f6343b authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix 2 minor issues, noticeable only in debug mode.

When reading board files, the net 0 was stored twice.
It creates only log messges in debug mode, because the list of nets is rebuild after reading files.
parent 20f0a5f8
...@@ -1381,14 +1381,11 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const ...@@ -1381,14 +1381,11 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
NETINFO_ITEM* net = m_NetInfo.GetNetItem( aNetcode ); NETINFO_ITEM* net = m_NetInfo.GetNetItem( aNetcode );
#if defined(DEBUG) #if defined(DEBUG)
if( net ) // item can be NULL if anetcode is not valid if( net && aNetcode != net->GetNet()) // item can be NULL if anetcode is not valid
{ {
if( aNetcode != net->GetNet() ) wxLogError( wxT( "FindNet() anetcode %d != GetNet() %d (net: %s)\n" ),
{
printf( "FindNet() anetcode %d != GetNet() %d (net: %s)\n",
aNetcode, net->GetNet(), TO_UTF8( net->GetNetname() ) ); aNetcode, net->GetNet(), TO_UTF8( net->GetNetname() ) );
} }
}
#endif #endif
return net; return net;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 24 2011) // C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -120,7 +120,7 @@ class DIALOG_MODULE_BOARD_EDITOR_BASE : public wxDialog ...@@ -120,7 +120,7 @@ class DIALOG_MODULE_BOARD_EDITOR_BASE : public wxDialog
public: public:
wxStaticBoxSizer* m_Sizer3DValues; wxStaticBoxSizer* m_Sizer3DValues;
DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 550,800 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 544,599 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_MODULE_BOARD_EDITOR_BASE(); ~DIALOG_MODULE_BOARD_EDITOR_BASE();
}; };
......
...@@ -1713,13 +1713,11 @@ void LEGACY_PLUGIN::loadPCB_LINE() ...@@ -1713,13 +1713,11 @@ void LEGACY_PLUGIN::loadPCB_LINE()
THROW_IO_ERROR( "Missing '$EndDRAWSEGMENT'" ); THROW_IO_ERROR( "Missing '$EndDRAWSEGMENT'" );
} }
void LEGACY_PLUGIN::loadNETINFO_ITEM() void LEGACY_PLUGIN::loadNETINFO_ITEM()
{ {
char buf[1024]; char buf[1024];
NETINFO_ITEM* net = new NETINFO_ITEM( m_board ); NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
m_board->AppendNet( net );
while( READLINE( m_reader ) ) while( READLINE( m_reader ) )
{ {
...@@ -1738,8 +1736,16 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM() ...@@ -1738,8 +1736,16 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
} }
else if( TESTLINE( "$EndEQUIPOT" ) ) else if( TESTLINE( "$EndEQUIPOT" ) )
{
// net 0 should be already in list, so store this net
// if it is not the net 0, or if the net 0 does not exists.
if( net->GetNet() > 0 || m_board->FindNet( 0 ) == NULL )
m_board->AppendNet( net );
else
delete net;
return; // preferred exit return; // preferred exit
} }
}
THROW_IO_ERROR( "Missing '$EndEQUIPOT'" ); THROW_IO_ERROR( "Missing '$EndEQUIPOT'" );
} }
...@@ -2135,8 +2141,11 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() ...@@ -2135,8 +2141,11 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
} }
zc->SetTimeStamp( timestamp ); zc->SetTimeStamp( timestamp );
zc->SetNet( netcode ); // Init the net code only, not the netname, to be sure
zc->SetNetName( FROM_UTF8( buf ) ); // the zone net name is the name read in file.
// (When mismatch, the user will be prompted in DRC, to fix the actual name)
zc->BOARD_CONNECTED_ITEM::SetNet( netcode );
zc->SetNetName( FROM_UTF8( buf ) ); // init the net name here
} }
else if( TESTLINE( "ZLayer" ) ) // layer found else if( TESTLINE( "ZLayer" ) ) // layer found
......
...@@ -605,7 +605,7 @@ void PCB_PARSER::parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR ) ...@@ -605,7 +605,7 @@ void PCB_PARSER::parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR )
default: default:
wxString err; wxString err;
err.Printf( _( "%d is not a valid title block comment number" ), commentNumber ); err.Printf( wxT( "%d is not a valid title block comment number" ), commentNumber );
THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
...@@ -705,7 +705,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR ) ...@@ -705,7 +705,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
if( it == m_layerMap.end() ) if( it == m_layerMap.end() )
{ {
wxString error; wxString error;
error.Printf( _( "Layer '%s' in file <%s> at line %d, position %d was not defined in the layers section" ), error.Printf( wxT( "Layer '%s' in file <%s> at line %d, position %d was not defined in the layers section" ),
GetChars( name ), GetChars( CurSource() ), CurLineNumber(), CurOffset() ); GetChars( name ), GetChars( CurSource() ), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error ); THROW_IO_ERROR( error );
} }
...@@ -720,7 +720,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR ) ...@@ -720,7 +720,7 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR )
if( !m_board->IsLayerEnabled( layerIndex ) ) if( !m_board->IsLayerEnabled( layerIndex ) )
{ {
wxString error; wxString error;
error.Printf( _( "Layer index %d in file <%s> at line %d, offset %d was not defined in the layers section" ), error.Printf( wxT( "Layer index %d in file <%s> at line %d, offset %d was not defined in the layers section" ),
layerIndex, GetChars( CurSource() ), CurLineNumber(), CurOffset() ); layerIndex, GetChars( CurSource() ), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error ); THROW_IO_ERROR( error );
} }
...@@ -1003,10 +1003,16 @@ void PCB_PARSER::parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR ) ...@@ -1003,10 +1003,16 @@ void PCB_PARSER::parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR )
wxString name = FromUTF8(); wxString name = FromUTF8();
NeedRIGHT(); NeedRIGHT();
// net 0 should be already in list, so store this net
// if it is not the net 0, or if the net 0 does not exists.
// (TODO: a better test.)
if( number > 0 || m_board->FindNet( 0 ) == NULL )
{
NETINFO_ITEM* net = new NETINFO_ITEM( m_board ); NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
net->SetNet( number ); net->SetNet( number );
net->SetNetname( name ); net->SetNetname( name );
m_board->AppendNet( net ); m_board->AppendNet( net );
}
} }
...@@ -2322,7 +2328,10 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ) ...@@ -2322,7 +2328,10 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR )
switch( token ) switch( token )
{ {
case T_net: case T_net:
zone->SetNet( parseInt( "net number" ) ); // Init the net code only, not the netname, to be sure
// the zone net name is the name read in file.
// (When mismatch, the user will be prompted in DRC, to fix the actual name)
zone->BOARD_CONNECTED_ITEM::SetNet( parseInt( "net number" ) );
NeedRIGHT(); NeedRIGHT();
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment