Pcbnew: fix Bug #1413701 (Segfault on highlight "unconnected" net 0 in Pcbnew ). Also, remove now useless code and other very minor fixes.

This commit is contained in:
jean-pierre charras 2015-01-23 12:24:32 +01:00
parent ca065833ea
commit f0a52644ea
9 changed files with 19 additions and 35 deletions

View File

@ -88,8 +88,7 @@ void VRML2_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3
glScalef( matScale.x, matScale.y, matScale.z ); glScalef( matScale.x, matScale.y, matScale.z );
// Switch the locale to standard C (needed to print floating point numbers like 1.3) LOCALE_IO toggle; // Temporary switch the locale to standard C to r/w floats
SetLocaleTo_C_standard();
childs.clear(); childs.clear();
@ -117,7 +116,6 @@ void VRML2_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3
} }
fclose( m_file ); fclose( m_file );
SetLocaleTo_Default(); // revert to the current locale
// DBG( printf( "chils size:%lu\n", childs.size() ) ); // DBG( printf( "chils size:%lu\n", childs.size() ) );

View File

@ -37,6 +37,7 @@
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <potracelib.h> #include <potracelib.h>
#include <auxiliary.h> #include <auxiliary.h>
#include <common.h>
#include <bitmap2component.h> #include <bitmap2component.h>
@ -437,7 +438,7 @@ void BITMAPCONV_INFO::CreateOutputFile( BMP2CMP_MOD_LAYER aModLayer )
potrace_dpoint_t( *c )[3]; potrace_dpoint_t( *c )[3];
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C LOCALE_IO toggle; // Temporary switch the locale to standard C to r/w floats
// The layer name has meaning only for .kicad_mod files. // The layer name has meaning only for .kicad_mod files.
// For these files the header creates 2 invisible texts: value and ref // For these files the header creates 2 invisible texts: value and ref
@ -530,8 +531,6 @@ void BITMAPCONV_INFO::CreateOutputFile( BMP2CMP_MOD_LAYER aModLayer )
} }
OuputFileEnd(); OuputFileEnd();
setlocale( LC_NUMERIC, "" ); // revert to the current locale
} }

View File

@ -65,7 +65,7 @@ void GRID_TRICKS::getSelectedArea()
wxArrayInt cols = m_grid->GetSelectedCols(); wxArrayInt cols = m_grid->GetSelectedCols();
wxArrayInt rows = m_grid->GetSelectedRows(); wxArrayInt rows = m_grid->GetSelectedRows();
DBG(printf("topLeft.Count():%zd botRight:Count():%zd\n", topLeft.Count(), botRight.Count() );) DBG(printf("topLeft.Count():%d botRight:Count():%d\n", int( topLeft.Count() ), int( botRight.Count() ) );)
if( topLeft.Count() && botRight.Count() ) if( topLeft.Count() && botRight.Count() )
{ {

View File

@ -269,11 +269,6 @@ void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->SetPath( wxT( "drl_files" ) ); aCfg->SetPath( wxT( "drl_files" ) );
m_drillFileHistory.Load( *aCfg ); m_drillFileHistory.Load( *aCfg );
aCfg->SetPath( wxT( ".." ) ); aCfg->SetPath( wxT( ".." ) );
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
SetLocaleTo_Default();
} }

View File

@ -767,11 +767,6 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
if( m_DisplayOptions.m_DisplayModText < LINE || m_DisplayOptions.m_DisplayModText > SKETCH ) if( m_DisplayOptions.m_DisplayModText < LINE || m_DisplayOptions.m_DisplayModText > SKETCH )
m_DisplayOptions.m_DisplayModText = FILLED; m_DisplayOptions.m_DisplayModText = FILLED;
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
SetLocaleTo_Default( );
} }

View File

@ -1212,10 +1212,12 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
{ {
// the first valid netcode is 1 and the last is m_NetInfo.GetCount()-1. // the first valid netcode is 1 and the last is m_NetInfo.GetCount()-1.
// zero is reserved for "no connection" and is not used. // zero is reserved for "no connection" and is not actually a net.
// NULL is returned for non valid netcodes // NULL is returned for non valid netcodes
if( aNetcode == NETINFO_LIST::UNCONNECTED ) wxASSERT( m_NetInfo.GetNetCount() > 0 ); // net zero should exist
if( aNetcode == NETINFO_LIST::UNCONNECTED && m_NetInfo.GetNetCount() == 0 )
return &NETINFO_LIST::ORPHANED; return &NETINFO_LIST::ORPHANED;
else else
return m_NetInfo.GetNetItem( aNetcode ); return m_NetInfo.GetNetItem( aNetcode );

View File

@ -80,10 +80,7 @@ void NETINFO_ITEM::Draw( EDA_DRAW_PANEL* panel,
void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
{ {
int count;
wxString txt; wxString txt;
MODULE* module;
D_PAD* pad;
double lengthnet = 0.0; // This is the lenght of tracks on pcb double lengthnet = 0.0; // This is the lenght of tracks on pcb
double lengthPadToDie = 0.0; // this is the lenght of internal ICs connections double lengthPadToDie = 0.0; // this is the lenght of internal ICs connections
@ -92,12 +89,17 @@ void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
txt.Printf( wxT( "%d" ), GetNet() ); txt.Printf( wxT( "%d" ), GetNet() );
aList.push_back( MSG_PANEL_ITEM( _( "Net Code" ), txt, RED ) ); aList.push_back( MSG_PANEL_ITEM( _( "Net Code" ), txt, RED ) );
count = 0; // Warning: for netcode == NETINFO_LIST::ORPHANED, the parent or the board
module = m_parent->GetBoard()->m_Modules; // can be NULL
BOARD * board = m_parent ? m_parent->GetBoard() : NULL;
for( ; module != 0; module = module->Next() ) if( board == NULL )
return;
int count = 0;
for( MODULE* module = board->m_Modules; module != NULL; module = module->Next() )
{ {
for( pad = module->Pads(); pad != 0; pad = pad->Next() ) for( D_PAD* pad = module->Pads(); pad != 0; pad = pad->Next() )
{ {
if( pad->GetNetCode() == GetNet() ) if( pad->GetNetCode() == GetNet() )
{ {
@ -112,7 +114,7 @@ void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
count = 0; count = 0;
for( const TRACK *track = m_parent->GetBoard()->m_Track; track != NULL; track = track->Next() ) for( const TRACK *track = board->m_Track; track != NULL; track = track->Next() )
{ {
if( track->Type() == PCB_VIA_T ) if( track->Type() == PCB_VIA_T )
{ {

View File

@ -754,11 +754,6 @@ void PCB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption ); aCfg->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
aCfg->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools ); aCfg->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools );
aCfg->Read( SHOW_LAYER_MANAGER_TOOLS, &m_show_layer_manager_tools ); aCfg->Read( SHOW_LAYER_MANAGER_TOOLS, &m_show_layer_manager_tools );
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in cfg,
// but forget to back to current locale. So we call SetLocaleTo_Default
SetLocaleTo_Default( );
} }

View File

@ -51,7 +51,7 @@ int main( int argc, char** argv )
SPECCTRA_DB db; SPECCTRA_DB db;
bool failed = false; bool failed = false;
SetLocaleTo_C_standard( ); // Switch the locale to standard C LOCALE_IO toggle; // Temporary switch the locale to standard C to r/w floats
if( argc == 2 ) if( argc == 2 )
{ {
@ -87,8 +87,6 @@ int main( int argc, char** argv )
DSN::SESSION* ses = db.GetSESSION(); DSN::SESSION* ses = db.GetSESSION();
ses->Format( &db, 0 ); ses->Format( &db, 0 );
#endif #endif
SetLocaleTo_Default( ); // revert to the current locale
} }
//-----<dummy code>--------------------------------------------------- //-----<dummy code>---------------------------------------------------