← Back to team overview

kicad-developers team mailing list archive

Re: Bug: ThrowIOError with GetChars() formatting parameter

 

Le 04/12/2015 14:54, Wayne Stambaugh a écrit :
> Thanks Henner.  I'll take a look at it when I get a chance.  I'm sure
> this isn't the only place this pattern is used.  If you have a patch,
> please submit it.
> 
> Thanks,
> 
> Wayne
> 
> On 12/3/2015 3:46 AM, Henner Zeller wrote:
>> Hi,
>> Playing with the spectra import/export, I encountered a bug: in that
>> code are constructs such as
>>
>>    ThrowIOError( _("some formatting %s"), GetChars( someWxString ));
>>
>> They are ultimately dealt with wxString::PrintfV( fmt, args );
>>
>> The output, however, is not as expected. A someWxString with "REF**"
>> was only displayed as "R". Changing the GetChars() to TO_UTF8() works.
>>
>> I suspect that whatever is returned by GetChars() is not properly
>> passed through the var-args argument, while the simple const char* of
>> TO_UTF8() does work. I am not sure though if that is the 'right'
>> solution as this might be different on Windows ? So I'll leave this to
>> someone more knowledgeable in wxString quirks on different platforms

@Henner,

GetChars is a macro (defined in macros.h)
It returns a wxChar*, which is the right type here.

(GetChars was written to be equivalent to GetData(), during the time
GetData(), needed when using wxString::Print(), was removed from
wxWidgets, in a few 2.9.x versions)

- How to reproduce this issue (it can be different on Linux and on Windows)?

- What happens if you replace GetChars( someWxString ) by
someWxString.GetData()?

-- 
Jean-Pierre CHARRAS


Follow ups

References