summaryrefslogtreecommitdiffstats
path: root/src/tools/qstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/qstring.cpp')
-rw-r--r--src/tools/qstring.cpp73
1 files changed, 20 insertions, 53 deletions
diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp
index 9b76dd9c0..24339fcdb 100644
--- a/src/tools/qstring.cpp
+++ b/src/tools/qstring.cpp
@@ -1048,13 +1048,9 @@ TQStringData::TQStringData() : TQShared(),
islatin1(FALSE),
security_unpaged(FALSE) {
#ifdef QT_THREAD_SUPPORT
- mutex = new TQMutex( TRUE );
- mutex->lock();
+ mutex = new TQMutex(FALSE);
#endif // QT_THREAD_SUPPORT
ref();
-#ifdef QT_THREAD_SUPPORT
- mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
TQStringData::TQStringData(TQChar *u, uint l, uint m) : TQShared(),
@@ -1066,7 +1062,7 @@ TQStringData::TQStringData(TQChar *u, uint l, uint m) : TQShared(),
islatin1(FALSE),
security_unpaged(FALSE) {
#ifdef QT_THREAD_SUPPORT
- mutex = new TQMutex( TRUE );
+ mutex = new TQMutex(FALSE);
#endif // QT_THREAD_SUPPORT
}
@@ -1494,13 +1490,6 @@ TQString::TQString() :
d(0)
{
d = shared_null ? shared_null : makeSharedNull();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
/*!
@@ -1519,15 +1508,15 @@ TQString::TQString( TQChar ch )
TQString::TQString( const TQString &s ) :
d(s.d)
{
+ if (d != shared_null) {
#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
+ d->mutex->lock();
#endif // QT_THREAD_SUPPORT
-
- d->ref();
-
+ d->ref();
#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
+ d->mutex->unlock();
#endif // QT_THREAD_SUPPORT
+ }
}
/*!
@@ -1550,13 +1539,6 @@ TQString::TQString( int size, bool /*dummy*/ )
d = new TQStringData( uc, 0, l );
} else {
d = shared_null ? shared_null : (shared_null=new TQStringData);
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
}
@@ -1598,13 +1580,6 @@ TQString::TQString( const TQChar* unicode, uint length )
{
if ( !unicode && !length ) {
d = shared_null ? shared_null : makeSharedNull();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
else {
TQChar* uc = QT_ALLOC_QCHAR_VEC( length );
@@ -1689,22 +1664,19 @@ TQString::~TQString()
}
#endif
+ if (d == shared_null) {
+ return;
+ }
+
#ifdef QT_THREAD_SUPPORT
d->mutex->lock();
#endif // QT_THREAD_SUPPORT
if ( d->deref() ) {
- if ( d != shared_null ) {
#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
- d->deleteSelf();
- d = NULL;
- }
- else {
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
+ d->mutex->unlock();
#endif // QT_THREAD_SUPPORT
- }
+ d->deleteSelf();
+ d = NULL;
}
else {
#ifdef QT_THREAD_SUPPORT
@@ -1730,7 +1702,7 @@ void TQString::real_detach()
void TQString::deref()
{
- if ( d ) {
+ if ( d && (d != shared_null) ) {
#ifdef QT_THREAD_SUPPORT
d->mutex->lock();
#endif // QT_THREAD_SUPPORT
@@ -1788,13 +1760,15 @@ void TQStringData::deleteSelf()
*/
TQString &TQString::operator=( const TQString &s )
{
+ if (s.d != shared_null) {
#ifdef QT_THREAD_SUPPORT
- s.d->mutex->lock();
+ s.d->mutex->lock();
#endif // QT_THREAD_SUPPORT
- s.d->ref();
+ s.d->ref();
#ifdef QT_THREAD_SUPPORT
- s.d->mutex->unlock();
+ s.d->mutex->unlock();
#endif // QT_THREAD_SUPPORT
+ }
deref();
d = s.d;
@@ -6527,13 +6501,6 @@ TQString& TQString::setUnicode( const TQChar *unicode, uint len )
if ( d != shared_null ) { // beware of nullstring being set to nullstring
deref();
d = shared_null ? shared_null : makeSharedNull();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
}
else {