diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/ntqstring.h | 1 | ||||
-rw-r--r-- | src/tools/qstring.cpp | 34 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/tools/ntqstring.h b/src/tools/ntqstring.h index b1ad52b1a..4c4c4173e 100644 --- a/src/tools/ntqstring.h +++ b/src/tools/ntqstring.h @@ -388,6 +388,7 @@ struct Q_EXPORT TQStringData : public TQShared { bool security_unpaged : 1; TQMutex* mutex; + TQCString *cString; private: #if defined(TQ_DISABLE_COPY) diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp index 421ef009f..b610a91af 100644 --- a/src/tools/qstring.cpp +++ b/src/tools/qstring.cpp @@ -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? |