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.
(cherry picked from commit a2b04536d3
)
This commit is contained in:
@@ -621,9 +621,16 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN
|
|||||||
#else
|
#else
|
||||||
#error "unsupported Unicode representation"
|
#error "unsupported Unicode representation"
|
||||||
#endif
|
#endif
|
||||||
|
CFStringref ref = CFStringCreateWithBytes( kCFAllocatorDefault,
|
||||||
reset( CFStringCreateWithBytes( kCFAllocatorDefault,
|
(const UInt8*)data, size, cfencoding, false /* no BOM */ );
|
||||||
(const UInt8*)data, size, cfencoding, false /* no BOM */ ) );
|
if (ref)
|
||||||
|
{
|
||||||
|
reset( ref );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reset( wxCFRetain( CFSTR("") ) );
|
||||||
|
}
|
||||||
#else // not wxUSE_UNICODE
|
#else // not wxUSE_UNICODE
|
||||||
reset( CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
|
reset( CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
|
||||||
wxMacGetSystemEncFromFontEnc( encoding ) ) );
|
wxMacGetSystemEncFromFontEnc( encoding ) ) );
|
||||||
|
Reference in New Issue
Block a user