diff options
-rw-r--r-- | src/tools/qstring.cpp | 34 | ||||
-rw-r--r-- | src/tools/qstring.h | 1 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp index 1c796fe..5bb3761 100644 --- a/src/tools/qstring.cpp +++ b/src/tools/qstring.cpp @@ -1051,7 +1051,8 @@ QStringData::QStringData() : QShared(), issimpletext(TRUE), maxl(0), islatin1(FALSE), - security_unpaged(FALSE) { + security_unpaged(FALSE), + cString(0) { #if defined(QT_THREAD_SUPPORT) && defined(MAKE_QSTRING_THREAD_SAFE) mutex = new QMutex(FALSE); #endif // QT_THREAD_SUPPORT && MAKE_QSTRING_THREAD_SAFE @@ -1065,7 +1066,8 @@ QStringData::QStringData(QChar *u, uint l, uint m) : QShared(), issimpletext(FALSE), maxl(m), islatin1(FALSE), - security_unpaged(FALSE) { + security_unpaged(FALSE), + cString(0) { #if defined(QT_THREAD_SUPPORT) && defined(MAKE_QSTRING_THREAD_SAFE) mutex = new QMutex(FALSE); #endif // QT_THREAD_SUPPORT && MAKE_QSTRING_THREAD_SAFE @@ -1083,6 +1085,9 @@ QStringData::~QStringData() { if ( ascii ) { delete[] ascii; } + if (cString) { + delete cString; + } #if defined(QT_THREAD_SUPPORT) && defined(MAKE_QSTRING_THREAD_SAFE) if ( mutex ) { delete mutex; @@ -1096,6 +1101,10 @@ void QStringData::setDirty() { delete [] ascii; ascii = 0; } + if (cString) { + delete cString; + cString = 0; + } issimpletext = FALSE; } @@ -6026,6 +6035,10 @@ QCString QString::utf8() const ++ch; } rstr.truncate( cursor - (uchar*)rstr.data() ); + if (!d->cString) { + d->cString = new QCString; + } + *d->cString = rstr; return rstr; } @@ -6227,23 +6240,28 @@ QString QString::fromLatin1( const char* chars, int len ) QCString QString::local8Bit() const { + if (!d->cString) { + d->cString = new QCString; + } #ifdef QT_NO_TEXTCODEC - return latin1(); + *d->cString = QCString(latin1()); + return *d->cString; #else #ifdef Q_WS_X11 QTextCodec* codec = QTextCodec::codecForLocale(); - return codec - ? codec->fromUnicode(*this) - : QCString(latin1()); + *d->cString = codec ? codec->fromUnicode(*this) : QCString(latin1()); + return *d->cString; #endif #if defined( Q_WS_MACX ) return utf8(); #endif #if defined( Q_WS_MAC9 ) - return QCString(latin1()); //I'm evil.. + *d->cString = QCString(latin1()); //I'm evil.. + return *d->cString; #endif #ifdef Q_WS_WIN - return isNull() ? QCString("") : qt_winQString2MB( *this ); + *d->cString = isNull() ? QCString("") : qt_winQString2MB( *this ); + return *d->cString; #endif #ifdef Q_WS_QWS return utf8(); // ### if there is any 8 bit format supported? diff --git a/src/tools/qstring.h b/src/tools/qstring.h index 8715395..4c40ce8 100644 --- a/src/tools/qstring.h +++ b/src/tools/qstring.h @@ -384,6 +384,7 @@ struct Q_EXPORT QStringData : public QShared { bool security_unpaged : 1; QMutex* mutex; + QCString *cString; private: #if defined(Q_DISABLE_COPY) |