Automated update from Qt3

pull/1/head
Timothy Pearson 11 years ago
parent d5fcca47a6
commit d55c0cef4d

@ -44,6 +44,11 @@
#undef QT_NO_CAST_ASCII #undef QT_NO_CAST_ASCII
#endif #endif
// WARNING
// When MAKE_TQSTRING_THREAD_SAFE is defined, overall TQt3 performance suffers badly!
// TQString is thread unsafe in many other areas; perhaps this option is not even useful?
// #define MAKE_TQSTRING_THREAD_SAFE 1
#include "ntqstring.h" #include "ntqstring.h"
#include "ntqregexp.h" #include "ntqregexp.h"
#include "ntqdatastream.h" #include "ntqdatastream.h"
@ -87,9 +92,9 @@
#define ULLONG_MAX TQ_UINT64_C(18446744073709551615) #define ULLONG_MAX TQ_UINT64_C(18446744073709551615)
#endif #endif
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
#include "ntqmutex.h" #include "ntqmutex.h"
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
extern TQMutex *tqt_sharedStringMutex; extern TQMutex *tqt_sharedStringMutex;
@ -1047,9 +1052,9 @@ TQStringData::TQStringData() : TQShared(),
maxl(0), maxl(0),
islatin1(FALSE), islatin1(FALSE),
security_unpaged(FALSE) { security_unpaged(FALSE) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
mutex = new TQMutex(FALSE); mutex = new TQMutex(FALSE);
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
ref(); ref();
} }
@ -1061,9 +1066,9 @@ TQStringData::TQStringData(TQChar *u, uint l, uint m) : TQShared(),
maxl(m), maxl(m),
islatin1(FALSE), islatin1(FALSE),
security_unpaged(FALSE) { security_unpaged(FALSE) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
mutex = new TQMutex(FALSE); mutex = new TQMutex(FALSE);
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
TQStringData::~TQStringData() { TQStringData::~TQStringData() {
@ -1076,12 +1081,12 @@ TQStringData::~TQStringData() {
if ( ascii ) { if ( ascii ) {
delete[] ascii; delete[] ascii;
} }
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
if ( mutex ) { if ( mutex ) {
delete mutex; delete mutex;
mutex = NULL; mutex = NULL;
} }
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
void TQStringData::setDirty() { void TQStringData::setDirty() {
@ -1449,14 +1454,14 @@ QT_STATIC_CONST_IMPL TQChar TQChar::nbsp((ushort)0x00a0);
TQStringData* TQString::makeSharedNull() TQStringData* TQString::makeSharedNull()
{ {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
if (tqt_sharedStringMutex) tqt_sharedStringMutex->lock(); if (tqt_sharedStringMutex) tqt_sharedStringMutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if (TQString::shared_null) { if (TQString::shared_null) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
if (tqt_sharedStringMutex) tqt_sharedStringMutex->unlock(); if (tqt_sharedStringMutex) tqt_sharedStringMutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
return TQString::shared_null; return TQString::shared_null;
} }
@ -1466,9 +1471,9 @@ TQStringData* TQString::makeSharedNull()
that->d = TQString::shared_null; that->d = TQString::shared_null;
#endif #endif
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
if (tqt_sharedStringMutex) tqt_sharedStringMutex->unlock(); if (tqt_sharedStringMutex) tqt_sharedStringMutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
return TQString::shared_null; return TQString::shared_null;
} }
@ -1509,13 +1514,13 @@ TQString::TQString( const TQString &s ) :
d(s.d) d(s.d)
{ {
if (d != shared_null) { if (d != shared_null) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
d->ref(); d->ref();
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
} }
@ -1668,20 +1673,20 @@ TQString::~TQString()
return; return;
} }
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( d->deref() ) { if ( d->deref() ) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
d->deleteSelf(); d->deleteSelf();
d = NULL; d = NULL;
} }
else { else {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
} }
@ -1703,22 +1708,22 @@ void TQString::real_detach()
void TQString::deref() void TQString::deref()
{ {
if ( d && (d != shared_null) ) { if ( d && (d != shared_null) ) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( d->deref() ) { if ( d->deref() ) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( d != shared_null ) { if ( d != shared_null ) {
delete d; delete d;
} }
d = 0; d = 0;
} }
else { else {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
} }
} }
@ -1761,13 +1766,13 @@ void TQStringData::deleteSelf()
TQString &TQString::operator=( const TQString &s ) TQString &TQString::operator=( const TQString &s )
{ {
if (s.d != shared_null) { if (s.d != shared_null) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
s.d->mutex->lock(); s.d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
s.d->ref(); s.d->ref();
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
s.d->mutex->unlock(); s.d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
deref(); deref();
d = s.d; d = s.d;
@ -1875,9 +1880,9 @@ void TQString::truncate( uint newLen )
*/ */
void TQString::setLength( uint newLen ) void TQString::setLength( uint newLen )
{ {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( d->count != 1 || newLen > d->maxl || if ( d->count != 1 || newLen > d->maxl ||
( newLen * 4 < d->maxl && d->maxl > 4 ) ) { ( newLen * 4 < d->maxl && d->maxl > 4 ) ) {
@ -1888,24 +1893,24 @@ void TQString::setLength( uint newLen )
uint len = TQMIN( d->len, newLen ); uint len = TQMIN( d->len, newLen );
memcpy( nd, d->unicode, sizeof(TQChar) * len ); memcpy( nd, d->unicode, sizeof(TQChar) * len );
bool unpaged = d->security_unpaged; bool unpaged = d->security_unpaged;
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
deref(); deref();
d = new TQStringData( nd, newLen, newMax ); d = new TQStringData( nd, newLen, newMax );
setSecurityUnPaged(unpaged); setSecurityUnPaged(unpaged);
} }
else { else {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
} }
else { else {
d->len = newLen; d->len = newLen;
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
d->setDirty(); d->setDirty();
} }
} }
@ -1991,21 +1996,21 @@ void TQString::squeeze()
*/ */
void TQString::grow( uint newLen ) void TQString::grow( uint newLen )
{ {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( d->count != 1 || newLen > d->maxl ) { if ( d->count != 1 || newLen > d->maxl ) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
setLength( newLen ); setLength( newLen );
} }
else { else {
d->len = newLen; d->len = newLen;
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
d->setDirty(); d->setDirty();
} }
} }
@ -6404,19 +6409,19 @@ TQString TQString::fromUcs2( const unsigned short *str )
*/ */
TQChar& TQString::ref(uint i) { TQChar& TQString::ref(uint i) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( (d->count != 1) || (i >= d->len) ) { if ( (d->count != 1) || (i >= d->len) ) {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
subat( i ); subat( i );
} }
else { else {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
d->setDirty(); d->setDirty();
return d->unicode[i]; return d->unicode[i];
@ -6504,9 +6509,9 @@ TQString& TQString::setUnicode( const TQChar *unicode, uint len )
} }
} }
else { else {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( d->count != 1 || len > d->maxl || ( len * 4 < d->maxl && d->maxl > 4 ) ) { if ( d->count != 1 || len > d->maxl || ( len * 4 < d->maxl && d->maxl > 4 ) ) {
// detach, grown or shrink // detach, grown or shrink
uint newMax = computeNewMax( len ); uint newMax = computeNewMax( len );
@ -6514,17 +6519,17 @@ TQString& TQString::setUnicode( const TQChar *unicode, uint len )
if ( unicode ) { if ( unicode ) {
memcpy( nd, unicode, sizeof(TQChar)*len ); memcpy( nd, unicode, sizeof(TQChar)*len );
} }
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
deref(); deref();
d = new TQStringData( nd, len, newMax ); d = new TQStringData( nd, len, newMax );
} }
else { else {
d->len = len; d->len = len;
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
d->setDirty(); d->setDirty();
if ( unicode ) { if ( unicode ) {
memcpy( d->unicode, unicode, sizeof(TQChar)*len ); memcpy( d->unicode, unicode, sizeof(TQChar)*len );
@ -7235,9 +7240,9 @@ TQConstString::TQConstString( const TQChar* unicode, uint length ) :
*/ */
TQConstString::~TQConstString() TQConstString::~TQConstString()
{ {
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
if ( d->count > 1 ) { if ( d->count > 1 ) {
TQChar* cp = QT_ALLOC_QCHAR_VEC( d->len ); TQChar* cp = QT_ALLOC_QCHAR_VEC( d->len );
@ -7249,9 +7254,9 @@ TQConstString::~TQConstString()
} }
// The original d->unicode is now unlinked. // The original d->unicode is now unlinked.
#ifdef QT_THREAD_SUPPORT #if defined(QT_THREAD_SUPPORT) && defined(MAKE_TQSTRING_THREAD_SAFE)
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT && MAKE_TQSTRING_THREAD_SAFE
} }
/*! /*!

Loading…
Cancel
Save