From eaef5c1043de3d28607e75cb52725c8dfb89e331 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Dec 2015 09:13:35 +0100 Subject: [PATCH] * Replace questionable wxString::PrintfV() call (which doesn't work reliably on different platforms) with wxString::Format() * Extra win: due to use now of the THROW_IO_ERROR() macro, error messages contain line numbers. --- pcbnew/specctra.cpp | 14 ----------- pcbnew/specctra.h | 2 -- pcbnew/specctra_export.cpp | 19 +++++++-------- pcbnew/specctra_import.cpp | 49 ++++++++++++++++++-------------------- 4 files changed, 32 insertions(+), 52 deletions(-) diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp index 2358d3b07d..92ac465810 100644 --- a/pcbnew/specctra.cpp +++ b/pcbnew/specctra.cpp @@ -131,20 +131,6 @@ int SPECCTRA_DB::findLayerName( const std::string& aLayerName ) const return -1; } - -void SPECCTRA_DB::ThrowIOError( const wxString& fmt, ... ) throw( IO_ERROR ) -{ - wxString errText; - va_list args; - - va_start( args, fmt ); - errText.PrintfV( fmt, args ); - va_end( args ); - - THROW_IO_ERROR( errText ); -} - - void SPECCTRA_DB::readCOMPnPIN( std::string* component_id, std::string* pin_id ) throw( IO_ERROR ) { T tok; diff --git a/pcbnew/specctra.h b/pcbnew/specctra.h index 540fcf9b13..f9ce20a861 100644 --- a/pcbnew/specctra.h +++ b/pcbnew/specctra.h @@ -3919,8 +3919,6 @@ public: */ void LoadSESSION( const wxString& filename ) throw( IO_ERROR, boost::bad_pointer ); - void ThrowIOError( const wxString& fmt, ... ) throw( IO_ERROR ); - /** * Function ExportPCB * writes the internal PCB instance out as a SPECTRA DSN format file. diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 1754189bf6..7b760b4ae2 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -1025,7 +1025,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) wxString error = wxString::Format( _( "Unsupported DRAWSEGMENT type %s" ), GetChars( BOARD_ITEM::ShowShape( graphic->GetShape() ) ) ); - ThrowIOError( error ); + THROW_IO_ERROR( error ); } break; } @@ -1132,7 +1132,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) wxString error = wxString::Format( _( "Unsupported DRAWSEGMENT type %s" ), GetChars( BOARD_ITEM::ShowShape( graphic->GetShape() ) ) ); - ThrowIOError( error ); + THROW_IO_ERROR( error ); } break; } @@ -1159,7 +1159,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) GetChars( FROM_UTF8( BOARD_ITEM::FormatInternalUnits( prevPt.x ).c_str() ) ), GetChars( FROM_UTF8( BOARD_ITEM::FormatInternalUnits( prevPt.y ).c_str() ) ) ); - ThrowIOError( error ); + THROW_IO_ERROR( error ); } break; } @@ -1268,7 +1268,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) _( "Unsupported DRAWSEGMENT type %s" ), GetChars( BOARD_ITEM::ShowShape( graphic->GetShape() ) ) ); - ThrowIOError( error ); + THROW_IO_ERROR( error ); } break; } @@ -1296,7 +1296,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) GetChars( FROM_UTF8( BOARD_ITEM::FormatInternalUnits( prevPt.y ).c_str() ) ) ); - ThrowIOError( error ); + THROW_IO_ERROR( error ); } break; } @@ -1449,16 +1449,16 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) if( module->GetReference() == wxEmptyString ) { - ThrowIOError( _( "Component with value of '%s' has empty reference id." ), - GetChars( module->GetValue() ) ); + THROW_IO_ERROR( wxString::Format( _( "Component with value of '%s' has empty reference id." ), + GetChars( module->GetValue() ) ) ); } // if we cannot insert OK, that means the reference has been seen before. STRINGSET_PAIR refpair = refs.insert( TO_UTF8( module->GetReference() ) ); if( !refpair.second ) // insert failed { - ThrowIOError( _( "Multiple components have identical reference IDs of '%s'." ), - GetChars( module->GetReference() ) ); + THROW_IO_ERROR( wxString::Format( _( "Multiple components have identical reference IDs of '%s'." ), + GetChars( module->GetReference() ) ) ); } } } @@ -2235,4 +2235,3 @@ void SPECCTRA_DB::RevertMODULEs( BOARD* aBoard ) } } // namespace DSN - diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index b8e2d86090..984ab4e33c 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -197,8 +197,8 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro if( layerNdx == -1 ) { wxString layerName = FROM_UTF8( aPath->layer_id.c_str() ); - ThrowIOError( _("Session file uses invalid layer id \"%s\""), - GetChars( layerName ) ); + THROW_IO_ERROR( wxString::Format( _("Session file uses invalid layer id \"%s\""), + GetChars( layerName ) ) ); } TRACK* track = new TRACK( sessionBoard ); @@ -250,15 +250,15 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro if( shapeCount == 0 ) { - ThrowIOError( _( "Session via padstack has no shapes" ) ); + THROW_IO_ERROR( _( "Session via padstack has no shapes" ) ); } else if( shapeCount == 1 ) { shape = (SHAPE*) (*aPadstack)[0]; DSN_T type = shape->shape->Type(); if( type != T_circle ) - ThrowIOError( _( "Unsupported via shape: %s"), - GetChars( GetTokenString( type ) ) ); + THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s"), + GetChars( GetTokenString( type ) ) ) ); CIRCLE* circle = (CIRCLE*) shape->shape; int viaDiam = scale( circle->diameter, routeResolution ); @@ -275,8 +275,8 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro shape = (SHAPE*) (*aPadstack)[0]; DSN_T type = shape->shape->Type(); if( type != T_circle ) - ThrowIOError( _( "Unsupported via shape: %s"), - GetChars( GetTokenString( type ) ) ); + THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s"), + GetChars( GetTokenString( type ) ) ) ); CIRCLE* circle = (CIRCLE*) shape->shape; int viaDiam = scale( circle->diameter, routeResolution ); @@ -300,8 +300,8 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro shape = (SHAPE*) (*aPadstack)[i]; DSN_T type = shape->shape->Type(); if( type != T_circle ) - ThrowIOError( _( "Unsupported via shape: %s"), - GetChars( GetTokenString( type ) ) ); + THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s"), + GetChars( GetTokenString( type ) ) ) ); CIRCLE* circle = (CIRCLE*) shape->shape; @@ -309,8 +309,8 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro if( layerNdx == -1 ) { wxString layerName = FROM_UTF8( circle->layer_id.c_str() ); - ThrowIOError( _("Session file uses invalid layer id \"%s\""), - GetChars( layerName ) ); + THROW_IO_ERROR( wxString::Format( _("Session file uses invalid layer id \"%s\""), + GetChars( layerName ) ) ); } if( layerNdx > topLayerNdx ) @@ -356,18 +356,18 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) sessionBoard = aBoard; // not owned here if( !session ) - ThrowIOError( _("Session file is missing the \"session\" section") ); + THROW_IO_ERROR( _("Session file is missing the \"session\" section") ); /* Dick 16-Jan-2012: session need not have a placement section. if( !session->placement ) - ThrowIOError( _("Session file is missing the \"placement\" section") ); + THROW_IO_ERROR( _("Session file is missing the \"placement\" section") ); */ if( !session->route ) - ThrowIOError( _("Session file is missing the \"routes\" section") ); + THROW_IO_ERROR( _("Session file is missing the \"routes\" section") ); if( !session->route->library ) - ThrowIOError( _("Session file is missing the \"library_out\" section") ); + THROW_IO_ERROR( _("Session file is missing the \"library_out\" section") ); // delete all the old tracks and vias aBoard->m_Track.DeleteAll(); @@ -393,9 +393,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) MODULE* module = aBoard->FindModuleByReference( reference ); if( !module ) { - ThrowIOError( - _("Session file has 'reference' to non-existent component \"%s\""), - GetChars( reference ) ); + THROW_IO_ERROR( wxString::Format( _("Session file has 'reference' to non-existent component \"%s\""), + GetChars( reference ) ) ); } if( !place->hasVertex ) @@ -478,11 +477,10 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) 'wire'. wxString netId = FROM_UTF8( wire->net_id.c_str() ); - ThrowIOError( - _("Unsupported wire shape: \"%s\" for net: \"%s\""), - DLEX::GetTokenString(shape).GetData(), - netId.GetData() - ); + THROW_IO_ERROR( wxString::Format( _("Unsupported wire shape: \"%s\" for net: \"%s\""), + DLEX::GetTokenString(shape).GetData(), + netId.GetData() + ) ); */ } else @@ -542,8 +540,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) // wire_via to text and put that text into the exception. wxString psid( FROM_UTF8( wire_via->GetPadstackId().c_str() ) ); - ThrowIOError( _("A wire_via references a missing padstack \"%s\""), - GetChars( psid ) ); + THROW_IO_ERROR( wxString::Format( _("A wire_via references a missing padstack \"%s\""), + GetChars( psid ) ) ); } NETCLASSPTR netclass = aBoard->GetDesignSettings().m_NetClasses.GetDefault(); @@ -561,4 +559,3 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) } // namespace DSN -