Eeschema: fix incorrect UI messages in dialogs due to using UTF8 strings instead of wxStrings (unicode) to build them.

(Added a explicit to build a Unicode string in UI messages to avoid mistakes)
This commit is contained in:
jean-pierre charras 2018-04-29 15:45:11 +02:00
parent c8a784058e
commit b636aaddf6
5 changed files with 29 additions and 9 deletions

View File

@ -66,7 +66,7 @@ public:
// Returns a string like mylib:symbol_name from the LIB_ID of the component
wxString GetStringLibId()
{
return wxString( m_Component->GetLibId().Format().c_str() );
return m_Component->GetLibId().GetUniStringLibId();
}
// Returns a string containing the reference of the component

View File

@ -409,11 +409,13 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
// Now that the fields are loaded we can set the initial location of the splitter
// based on the list width. Again, SetWidth( wxCOL_WIDTH_AUTOSIZE ) fails us on GTK.
int nameColWidth = 0;
for( unsigned int row = 0; row < m_fieldsCtrl->GetItemCount(); ++row )
for( int row = 0; row < m_fieldsCtrl->GetItemCount(); ++row )
{
const wxString& fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN );
nameColWidth = std::max( nameColWidth, GetTextSize( fieldName, m_fieldsCtrl ).x );
}
m_fieldsCtrl->GetColumn( FIELD_NAME_COLUMN )->SetWidth( nameColWidth );
m_splitter1->SetSashPosition( nameColWidth + m_showColWidth + m_groupByColWidth + 40 );

View File

@ -99,8 +99,8 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
catch( const IO_ERROR& )
{
// Queue up error messages for later.
tmp.Printf( _( "Failed to add symbol %s to library file." ),
component->GetLibId().GetLibItemName().wx_str(), aFileName );
tmp.Printf( _( "Failed to add symbol \"%s\" to library file \"%s\"." ),
component->GetLibId().GetUniStringLibItemName(), aFileName );
// Don't bail out here. Attempt to add as many of the symbols to the library
// as possible.
@ -114,7 +114,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
{
// Use the full LIB_ID as the symbol name to prevent symbol name collisions.
wxString oldName = part->GetName();
part->SetName( component->GetLibId().Format() );
part->SetName( component->GetLibId().GetUniStringLibId() );
// AddPart() does first clone the part before adding.
archLib->AddPart( part );
@ -123,7 +123,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
else
{
tmp.Printf( _( "Symbol %s not found in any library or cache." ),
component->GetLibId().Format().wx_str() );
component->GetLibId().GetUniStringLibId() );
}
if( !tmp.empty() )

View File

@ -373,7 +373,8 @@ void LIB_EDIT_FRAME::OnRemovePart( wxCommandEvent& aEvent )
if( m_libMgr->IsPartModified( libId.GetLibItemName(), libId.GetLibNickname() )
&& !IsOK( this, _( wxString::Format( "Component %s has been modified\n"
"Do you want to remove it from the library?", libId.GetLibItemName().c_str() ) ) ) )
"Do you want to remove it from the library?",
libId.GetUniStringLibItemName() ) ) ) )
{
return;
}

View File

@ -113,10 +113,17 @@ public:
int SetLibNickname( const UTF8& aNickname );
/**
* @return the library item name, i.e. footprintName.
* @return the library item name, i.e. footprintName, in UTF8.
*/
const UTF8& GetLibItemName() const { return item_name; }
/**
* @return the library item name, i.e. footprintName in a wxString (UTF16 or 32).
* useful to display messages in dialogs
* Equivalent to item_name.wx_str(), but more explicit when building a Unicode string in messages.
*/
const wxString GetUniStringLibItemName() const { return item_name.wx_str(); }
/**
* Override the library item name portion of the LIB_ID to @a aLibItemName
*
@ -133,10 +140,20 @@ public:
UTF8 GetLibItemNameAndRev() const;
/**
* @return the fully formatted text of the LIB_ID.
* @return the fully formatted text of the LIB_ID in a UTF8 string.
*/
UTF8 Format() const;
/**
* @return the fully formatted text of the LIB_ID in a wxString (UTF16 or UTF32),
* suitable to display the LIB_ID in dialogs.
* Equivalent to Format().wx_str(), but more explicit when building a Unicode string in messages.
*/
wxString GetUniStringLibId() const
{
return Format().wx_str();
}
/**
* @return a string in the proper format as an LIB_ID for a combination of
* aLibNickname, aLibItemName, and aRevision.