fix for #9045
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@54745 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -66,6 +66,8 @@
|
|||||||
|
|
||||||
// includes Mac headers
|
// includes Mac headers
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -2800,10 +2802,12 @@ public:
|
|||||||
#else
|
#else
|
||||||
ubuf = (UniChar*) (buf ? buf : tbuf) ;
|
ubuf = (UniChar*) (buf ? buf : tbuf) ;
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
status = TECConvertText(
|
wxMutexLocker lock( m_MB2WC_guard );
|
||||||
|
status = TECConvertText(
|
||||||
m_MB2WC_converter, (ConstTextPtr) psz, byteInLen, &byteInLen,
|
m_MB2WC_converter, (ConstTextPtr) psz, byteInLen, &byteInLen,
|
||||||
(TextPtr) ubuf, byteBufferLen, &byteOutLen);
|
(TextPtr) ubuf, byteBufferLen, &byteOutLen);
|
||||||
|
}
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
// we have to terminate here, because n might be larger for the trailing zero, and if UniChar
|
// we have to terminate here, because n might be larger for the trailing zero, and if UniChar
|
||||||
@@ -2854,10 +2858,13 @@ public:
|
|||||||
ubuf = (UniChar*) psz ;
|
ubuf = (UniChar*) psz ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status = TECConvertText(
|
{
|
||||||
|
wxMutexLocker lock( m_WC2MB_guard );
|
||||||
|
status = TECConvertText(
|
||||||
m_WC2MB_converter, (ConstTextPtr) ubuf, byteInLen, &byteInLen,
|
m_WC2MB_converter, (ConstTextPtr) ubuf, byteInLen, &byteInLen,
|
||||||
(TextPtr) (buf ? buf : tbuf), byteBufferLen, &byteOutLen);
|
(TextPtr) (buf ? buf : tbuf), byteBufferLen, &byteOutLen);
|
||||||
|
}
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
free( ubuf ) ;
|
free( ubuf ) ;
|
||||||
#endif
|
#endif
|
||||||
@@ -2898,6 +2905,9 @@ public:
|
|||||||
protected :
|
protected :
|
||||||
mutable TECObjectRef m_MB2WC_converter;
|
mutable TECObjectRef m_MB2WC_converter;
|
||||||
mutable TECObjectRef m_WC2MB_converter;
|
mutable TECObjectRef m_WC2MB_converter;
|
||||||
|
|
||||||
|
mutable wxMutex m_MB2WC_guard;
|
||||||
|
mutable wxMutex m_WC2MB_guard;
|
||||||
|
|
||||||
TextEncodingBase m_char_encoding;
|
TextEncodingBase m_char_encoding;
|
||||||
TextEncodingBase m_unicode_encoding;
|
TextEncodingBase m_unicode_encoding;
|
||||||
@@ -2958,15 +2968,18 @@ public :
|
|||||||
ByteCount dcubufread , dcubufwritten ;
|
ByteCount dcubufread , dcubufwritten ;
|
||||||
UniChar *dcubuf = (UniChar*) malloc( dcubuflen ) ;
|
UniChar *dcubuf = (UniChar*) malloc( dcubuflen ) ;
|
||||||
|
|
||||||
ConvertFromUnicodeToText( m_uni , byteInLen , ubuf ,
|
{
|
||||||
kUnicodeDefaultDirectionMask, 0, NULL, NULL, NULL, dcubuflen , &dcubufread , &dcubufwritten , dcubuf ) ;
|
wxMutexLocker lock( m_WC2MB_guard );
|
||||||
|
ConvertFromUnicodeToText( m_uni , byteInLen , ubuf ,
|
||||||
|
kUnicodeDefaultDirectionMask, 0, NULL, NULL, NULL, dcubuflen , &dcubufread , &dcubufwritten , dcubuf ) ;
|
||||||
|
|
||||||
// we now convert that decomposed buffer into UTF8
|
// we now convert that decomposed buffer into UTF8
|
||||||
|
|
||||||
status = TECConvertText(
|
status = TECConvertText(
|
||||||
m_WC2MB_converter, (ConstTextPtr) dcubuf, dcubufwritten, &dcubufread,
|
m_WC2MB_converter, (ConstTextPtr) dcubuf, dcubufwritten, &dcubufread,
|
||||||
(TextPtr) (buf ? buf : tbuf), byteBufferLen, &byteOutLen);
|
(TextPtr) (buf ? buf : tbuf), byteBufferLen, &byteOutLen);
|
||||||
|
}
|
||||||
|
|
||||||
free( dcubuf );
|
free( dcubuf );
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
@@ -3015,16 +3028,19 @@ public :
|
|||||||
ByteCount dcubufread , dcubufwritten ;
|
ByteCount dcubufread , dcubufwritten ;
|
||||||
UniChar *dcubuf = (UniChar*) malloc( dcubuflen ) ;
|
UniChar *dcubuf = (UniChar*) malloc( dcubuflen ) ;
|
||||||
|
|
||||||
status = TECConvertText(
|
{
|
||||||
|
wxMutexLocker lock( m_MB2WC_guard );
|
||||||
|
status = TECConvertText(
|
||||||
m_MB2WC_converter, (ConstTextPtr) psz, byteInLen, &byteInLen,
|
m_MB2WC_converter, (ConstTextPtr) psz, byteInLen, &byteInLen,
|
||||||
(TextPtr) dcubuf, dcubuflen, &byteOutLen);
|
(TextPtr) dcubuf, dcubuflen, &byteOutLen);
|
||||||
// we have to terminate here, because n might be larger for the trailing zero, and if UniChar
|
// we have to terminate here, because n might be larger for the trailing zero, and if UniChar
|
||||||
// is not properly terminated we get random characters at the end
|
// is not properly terminated we get random characters at the end
|
||||||
dcubuf[byteOutLen / sizeof( UniChar ) ] = 0 ;
|
dcubuf[byteOutLen / sizeof( UniChar ) ] = 0 ;
|
||||||
|
|
||||||
// now from the decomposed UniChar to properly composed uniChar
|
// now from the decomposed UniChar to properly composed uniChar
|
||||||
ConvertFromUnicodeToText( m_uniBack , byteOutLen , dcubuf ,
|
ConvertFromUnicodeToText( m_uniBack , byteOutLen , dcubuf ,
|
||||||
kUnicodeDefaultDirectionMask, 0, NULL, NULL, NULL, dcubuflen , &dcubufread , &dcubufwritten , ubuf ) ;
|
kUnicodeDefaultDirectionMask, 0, NULL, NULL, NULL, dcubuflen , &dcubufread , &dcubufwritten , ubuf ) ;
|
||||||
|
}
|
||||||
|
|
||||||
free( dcubuf );
|
free( dcubuf );
|
||||||
byteOutLen = dcubufwritten ;
|
byteOutLen = dcubufwritten ;
|
||||||
|
Reference in New Issue
Block a user