From b9eb3e9b0528f6e4c89c40e22d493c0fed49f248 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 3 Feb 2022 21:47:10 +0000 Subject: [PATCH] Be more explicit about string conversions. --- common/dialog_shim.cpp | 13 ++++++------- common/font/font.cpp | 10 +++++----- common/project/project_file.cpp | 2 +- eeschema/cross-probing.cpp | 6 +++--- eeschema/sch_connection.cpp | 14 +++----------- pcbnew/pad.cpp | 2 +- 6 files changed, 19 insertions(+), 28 deletions(-) diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 74a478af49..adb85ad83b 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2012-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -449,8 +449,8 @@ int DIALOG_SHIM::ShowQuasiModal() // Get the optimal parent wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() ); - wxASSERT_MSG( !m_qmodal_parent_disabler, - wxT( "Caller using ShowQuasiModal() twice on same window?" ) ); + wxASSERT_MSG( !m_qmodal_parent_disabler, wxT( "Caller using ShowQuasiModal() twice on same " + "window?" ) ); // quasi-modal: disable only my "optimal" parent m_qmodal_parent_disabler = new WDO_ENABLE_DISABLE( parent ); @@ -488,8 +488,8 @@ void DIALOG_SHIM::EndQuasiModal( int retCode ) if( !IsQuasiModal() ) { - wxFAIL_MSG( "either DIALOG_SHIM::EndQuasiModal called twice or ShowQuasiModal" - "wasn't called" ); + wxFAIL_MSG( wxT( "Either DIALOG_SHIM::EndQuasiModal was called twice, or ShowQuasiModal" + "wasn't called" ) ); return; } @@ -549,8 +549,7 @@ void DIALOG_SHIM::OnButton( wxCommandEvent& aEvent ) ignore_unused( TransferDataFromWindow() ); } } - else if( id == GetEscapeId() || - (id == wxID_CANCEL && GetEscapeId() == wxID_ANY) ) + else if( id == GetEscapeId() || (id == wxID_CANCEL && GetEscapeId() == wxID_ANY) ) { EndQuasiModal( wxID_CANCEL ); } diff --git a/common/font/font.cpp b/common/font/font.cpp index 8b0d9d1944..32be8d1692 100644 --- a/common/font/font.cpp +++ b/common/font/font.cpp @@ -374,14 +374,14 @@ void wordbreakMarkup( std::vector>* aWords, } else { - wxString space( wxT( " " ) ); + wxString space( wxS( " " ) ); wxString textRun( aNode->string() ); wxArrayString words; wxStringSplit( textRun, words, ' ' ); - if( textRun.EndsWith( " " ) ) - words.Add( " " ); + if( textRun.EndsWith( wxS( " " ) ) ) + words.Add( wxS( " " ) ); for( size_t ii = 0; ii < words.size(); ++ii ) { @@ -430,8 +430,8 @@ void FONT::LinebreakText( wxString& aText, int aColumnWidth, const VECTOR2I& aSi if( aItalic ) textStyle |= TEXT_STYLE::ITALIC; - int spaceWidth = GetTextAsGlyphs( nullptr, nullptr, " ", aSize, VECTOR2I(), ANGLE_0, false, - VECTOR2I(), textStyle ).x; + int spaceWidth = GetTextAsGlyphs( nullptr, nullptr, wxS( " " ), aSize, VECTOR2I(), ANGLE_0, + false, VECTOR2I(), textStyle ).x; wxArrayString textLines; wxStringSplit( aText, textLines, '\n' ); diff --git a/common/project/project_file.cpp b/common/project/project_file.cpp index 05f2c116dd..2704402c00 100644 --- a/common/project/project_file.cpp +++ b/common/project/project_file.cpp @@ -488,7 +488,7 @@ bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg ) std::vector groups; - groups.emplace_back( "" ); + groups.emplace_back( wxEmptyString ); auto loadLegacyPairs = [&]( const std::string& aGroup ) -> bool diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 835f88c91e..5a7e757558 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -488,7 +488,7 @@ std::string FormatProbeItems( bool aSelectConnections, const std::dequeGetField( REFERENCE_FIELD )->GetText(); - parts.insert( "F" + EscapeString( ref, CTX_IPC ) ); + parts.insert( wxT( "F" ) + EscapeString( ref, CTX_IPC ) ); break; } @@ -515,7 +515,7 @@ std::string FormatProbeItems( bool aSelectConnections, const std::dequem_Uuid.AsString(); - parts.insert( "S" + full_path ); + parts.insert( wxT( "S" ) + full_path ); break; } @@ -527,7 +527,7 @@ std::string FormatProbeItems( bool aSelectConnections, const std::dequeGetField( REFERENCE_FIELD )->GetText(); - parts.insert( "P" + EscapeString( ref, CTX_IPC ) + "/" + parts.insert( wxT( "P" ) + EscapeString( ref, CTX_IPC ) + wxT( "/" ) + EscapeString( pin->GetShownNumber(), CTX_IPC ) ); break; diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index 0e38794709..de33f8b690 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -407,14 +407,6 @@ void SCH_CONNECTION::AppendInfoToMsgPanel( std::vector& aList ) aList.emplace_back( _( "Connection Name" ), UnescapeString( Name() ) ); - // NOTE(JE) Disabling this for now, because net codes are generated in the netlist exporter - // in order to avoid sort costs. It may make sense to just tear out net codes from the - // CONNECTION_GRAPH entirely in the future, as they are mostly only useful for netlist exports. -#if 0 - if( !IsBus() ) - aList.emplace_back( _( "Net Code" ), wxString::Format( "%d", m_net_code ) ); -#endif - if( auto alias = m_graph->GetBusAlias( m_name ) ) { msg.Printf( _( "Bus Alias %s Members" ), m_name ); @@ -447,14 +439,14 @@ void SCH_CONNECTION::AppendInfoToMsgPanel( std::vector& aList ) return; if( IsBus() ) - aList.emplace_back( "Bus Code", wxString::Format( "%d", m_bus_code ) ); + aList.emplace_back( wxT( "Bus Code" ), wxString::Format( "%d", m_bus_code ) ); - aList.emplace_back( "Subgraph Code", wxString::Format( "%d", m_subgraph_code ) ); + aList.emplace_back( wxT( "Subgraph Code" ), wxString::Format( "%d", m_subgraph_code ) ); if( SCH_ITEM* driver = Driver() ) { msg.Printf( "%s at %p", driver->GetSelectMenuText( EDA_UNITS::MILLIMETRES ), driver ); - aList.emplace_back( "Connection Source", msg ); + aList.emplace_back( wxT( "Connection Source" ), msg ); } #endif } diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 60e57aa72d..5677442ec2 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -952,7 +952,7 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& } #if 0 // useful for debug only - aList.emplace_back( "UUID", m_Uuid.AsString() ); + aList.emplace_back( wxT( "UUID" ), m_Uuid.AsString() ); #endif }