create a true empty string and not a null CFStringRef
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33047 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -635,27 +635,32 @@ void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding encoding )
|
|||||||
{
|
{
|
||||||
Release() ;
|
Release() ;
|
||||||
if (st.IsEmpty())
|
if (st.IsEmpty())
|
||||||
return ;
|
{
|
||||||
|
m_cfs = CFSTR("") ;
|
||||||
wxString str = st ;
|
CFRetain( m_cfs ) ;
|
||||||
wxMacConvertNewlines13To10( &str ) ;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString str = st ;
|
||||||
|
wxMacConvertNewlines13To10( &str ) ;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
#if SIZEOF_WCHAR_T == 2
|
#if SIZEOF_WCHAR_T == 2
|
||||||
m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
(UniChar*)str.wc_str() , str.Len() );
|
(UniChar*)str.wc_str() , str.Len() );
|
||||||
#else
|
#else
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16BE converter ;
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||||
UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
|
UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
|
||||||
converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
|
converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
|
||||||
m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault ,
|
m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault ,
|
||||||
unibuf , unicharlen / sizeof(UniChar) ) ;
|
unibuf , unicharlen / sizeof(UniChar) ) ;
|
||||||
delete[] unibuf ;
|
delete[] unibuf ;
|
||||||
#endif
|
#endif
|
||||||
#else // not wxUSE_UNICODE
|
#else // not wxUSE_UNICODE
|
||||||
m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
|
m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
|
||||||
wxMacGetSystemEncFromFontEnc( encoding ) ) ;
|
wxMacGetSystemEncFromFontEnc( encoding ) ) ;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
m_release = true ;
|
m_release = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user