Work around the train-wreck that is wxString::Format.
Fixes https://gitlab.com/kicad/code/kicad/issues/9247
This commit is contained in:
parent
544fa939f8
commit
956ec5b17c
|
@ -507,6 +507,27 @@ void CVPCB_MAINFRAME::RedoAssociation()
|
|||
}
|
||||
|
||||
|
||||
wxString CVPCB_MAINFRAME::formatSymbolDesc( int idx, const wxString& aReference,
|
||||
const wxString& aValue, const wxString& aFootprint )
|
||||
{
|
||||
// Work around a bug in wxString::Format with double-byte chars (and double-quote, for some
|
||||
// reason).
|
||||
wxString desc = wxString::Format( wxT( "%3d " ), idx );
|
||||
|
||||
for( int ii = aReference.Length(); ii < 8; ++ii )
|
||||
desc += wxS( " " );
|
||||
|
||||
desc += aReference + wxT( " - " );
|
||||
|
||||
for( int ii = aValue.Length(); ii < 16; ++ii )
|
||||
desc += wxS( " " );
|
||||
|
||||
desc += aValue + wxT( " : " ) + aFootprint;
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
|
||||
bool aNewEntry, bool aAddUndoItem )
|
||||
{
|
||||
|
@ -544,8 +565,7 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
|
|||
candidate->SetFPID( fpid );
|
||||
|
||||
// create the new symbol description and set it
|
||||
wxString description = wxString::Format( CMP_FORMAT,
|
||||
idx + 1,
|
||||
wxString description = formatSymbolDesc( idx + 1,
|
||||
candidate->GetReference(),
|
||||
candidate->GetValue(),
|
||||
candidate->GetFPID().Format().wx_str() );
|
||||
|
@ -911,8 +931,7 @@ void CVPCB_MAINFRAME::BuildSymbolsListBox()
|
|||
{
|
||||
symbol = m_netlist.GetComponent( i );
|
||||
|
||||
msg.Printf( CMP_FORMAT,
|
||||
m_symbolsListBox->GetCount() + 1,
|
||||
msg = formatSymbolDesc( m_symbolsListBox->GetCount() + 1,
|
||||
symbol->GetReference(),
|
||||
symbol->GetValue(),
|
||||
symbol->GetFPID().Format().wx_str() );
|
||||
|
|
|
@ -49,11 +49,6 @@ typedef std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES;
|
|||
// The undo list is a vector of undo entries
|
||||
typedef std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST;
|
||||
|
||||
/**
|
||||
* The print format to display a schematic component line.
|
||||
* format: idx reference - value : footprint_id
|
||||
*/
|
||||
#define CMP_FORMAT wxT( "%3d %8s - %16s : %s" )
|
||||
|
||||
/**
|
||||
* The CvPcb application main window.
|
||||
|
@ -343,6 +338,9 @@ protected:
|
|||
void setupUIConditions() override;
|
||||
|
||||
private:
|
||||
wxString formatSymbolDesc( int idx, const wxString& aReference, const wxString& aValue,
|
||||
const wxString& aFootprint );
|
||||
|
||||
/**
|
||||
* Setup the tool system for the CVPCB main frame.
|
||||
*/
|
||||
|
|
|
@ -263,7 +263,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
|
|||
{
|
||||
COMPONENT* component = m_netlist.GetComponent( i );
|
||||
|
||||
msg.Printf( CMP_FORMAT, m_symbolsListBox->GetCount() + 1,
|
||||
msg = formatSymbolDesc( m_symbolsListBox->GetCount() + 1,
|
||||
component->GetReference(),
|
||||
component->GetValue(),
|
||||
FROM_UTF8( component->GetFPID().Format().c_str() ) );
|
||||
|
|
Loading…
Reference in New Issue