Create empty wxCFStringRef and not null one if conversion fails
If the passed string cannot be represented in the target encoding in the wxCFStringRef constructor, create a reference to an empty string instead of a null ref. Most users of wxCFStringRef cannot handle a null wxCFStringRef. Closes #17825.
This commit is contained in:
parent
a9f83c879f
commit
a2b04536d3
@ -630,9 +630,16 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN
|
||||
#else
|
||||
#error "unsupported Unicode representation"
|
||||
#endif
|
||||
|
||||
reset( CFStringCreateWithBytes( kCFAllocatorDefault,
|
||||
(const UInt8*)data, size, cfencoding, false /* no BOM */ ) );
|
||||
CFStringref ref = CFStringCreateWithBytes( kCFAllocatorDefault,
|
||||
(const UInt8*)data, size, cfencoding, false /* no BOM */ );
|
||||
if (ref)
|
||||
{
|
||||
reset( ref );
|
||||
}
|
||||
else
|
||||
{
|
||||
reset( wxCFRetain( CFSTR("") ) );
|
||||
}
|
||||
#else // not wxUSE_UNICODE
|
||||
reset( CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
|
||||
wxMacGetSystemEncFromFontEnc( encoding ) ) );
|
||||
|
Loading…
Reference in New Issue
Block a user