Make use of TQString::utf8() and TQString::local8Bit() safe for conversion to char*.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/6/head
Slávek Banko 6 years ago
parent 74ba429758
commit 4e83f4f200
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -388,6 +388,7 @@ struct Q_EXPORT TQStringData : public TQShared {
bool security_unpaged : 1;
TQMutex* mutex;
TQCString *cString;
private:
#if defined(TQ_DISABLE_COPY)

@ -1052,7 +1052,8 @@ TQStringData::TQStringData() : TQShared(),
issimpletext(TRUE),
maxl(0),
islatin1(FALSE),
security_unpaged(FALSE) {
security_unpaged(FALSE),
cString(0) {
#if defined(TQT_THREAD_SUPPORT) && defined(MAKE_QSTRING_THREAD_SAFE)
mutex = new TQMutex(FALSE);
#endif // TQT_THREAD_SUPPORT && MAKE_QSTRING_THREAD_SAFE
@ -1066,7 +1067,8 @@ TQStringData::TQStringData(TQChar *u, uint l, uint m) : TQShared(),
issimpletext(FALSE),
maxl(m),
islatin1(FALSE),
security_unpaged(FALSE) {
security_unpaged(FALSE),
cString(0) {
#if defined(TQT_THREAD_SUPPORT) && defined(MAKE_QSTRING_THREAD_SAFE)
mutex = new TQMutex(FALSE);
#endif // TQT_THREAD_SUPPORT && MAKE_QSTRING_THREAD_SAFE
@ -1084,6 +1086,9 @@ TQStringData::~TQStringData() {
if ( ascii ) {
delete[] ascii;
}
if (cString) {
delete cString;
}
#if defined(TQT_THREAD_SUPPORT) && defined(MAKE_QSTRING_THREAD_SAFE)
if ( mutex ) {
delete mutex;
@ -1097,6 +1102,10 @@ void TQStringData::setDirty() {
delete [] ascii;
ascii = 0;
}
if (cString) {
delete cString;
cString = 0;
}
issimpletext = FALSE;
}
@ -6034,6 +6043,10 @@ TQCString TQString::utf8() const
++ch;
}
rstr.truncate( cursor - (uchar*)rstr.data() );
if (!d->cString) {
d->cString = new TQCString;
}
*d->cString = rstr;
return rstr;
}
@ -6235,23 +6248,28 @@ TQString TQString::fromLatin1( const char* chars, int len )
TQCString TQString::local8Bit() const
{
if (!d->cString) {
d->cString = new TQCString;
}
#ifdef TQT_NO_TEXTCODEC
return latin1();
*d->cString = TQCString(latin1());
return *d->cString;
#else
#ifdef Q_WS_X11
TQTextCodec* codec = TQTextCodec::codecForLocale();
return codec
? codec->fromUnicode(*this)
: TQCString(latin1());
*d->cString = codec ? codec->fromUnicode(*this) : TQCString(latin1());
return *d->cString;
#endif
#if defined( Q_WS_MACX )
return utf8();
#endif
#if defined( Q_WS_MAC9 )
return TQCString(latin1()); //I'm evil..
*d->cString = TQCString(latin1()); //I'm evil..
return *d->cString;
#endif
#ifdef Q_WS_WIN
return isNull() ? TQCString("") : qt_winTQString2MB( *this );
*d->cString = isNull() ? TQCString("") : qt_winTQString2MB( *this );
return *d->cString;
#endif
#ifdef Q_WS_QWS
return utf8(); // ### if there is any 8 bit format supported?

Loading…
Cancel
Save