summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index bb13ee9..06e4508 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -57,6 +57,7 @@
#include "qhash.h"
#include "qdebug.h"
#include "qendian.h"
+#include "qmutex.h"
#ifdef Q_OS_MAC
#include <private/qcore_mac_p.h>
@@ -104,6 +105,8 @@ QTextCodec *QString::codecForCStrings;
#ifdef QT3_SUPPORT
static QHash<void *, QByteArray> *asciiCache = 0;
+Q_GLOBAL_STATIC(QMutex, asciiCacheMutex)
+
#endif
#ifdef QT_USE_ICU
@@ -111,7 +114,6 @@ static QHash<void *, QByteArray> *asciiCache = 0;
extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result);
#endif
-
// internal
int qFindString(const QChar *haystack, int haystackLen, int from,
const QChar *needle, int needleLen, Qt::CaseSensitivity cs);
@@ -1225,6 +1227,7 @@ void QString::free(Data *d)
{
#ifdef QT3_SUPPORT
if (d->asciiCache) {
+ QMutexLocker locker(asciiCacheMutex());
Q_ASSERT(asciiCache);
asciiCache->remove(d);
}
@@ -1359,6 +1362,7 @@ void QString::realloc(int alloc)
} else {
#ifdef QT3_SUPPORT
if (d->asciiCache) {
+ QMutexLocker locker(asciiCacheMutex());
Q_ASSERT(asciiCache);
asciiCache->remove(d);
}
@@ -3905,6 +3909,7 @@ QString QString::fromLatin1(const char *str, int size)
*/
const char *QString::ascii_helper() const
{
+ QMutexLocker locker(asciiCacheMutex());
if (!asciiCache)
asciiCache = new QHash<void *, QByteArray>();
@@ -3922,6 +3927,7 @@ const char *QString::ascii_helper() const
*/
const char *QString::latin1_helper() const
{
+ QMutexLocker locker(asciiCacheMutex());
if (!asciiCache)
asciiCache = new QHash<void *, QByteArray>();
@@ -7239,6 +7245,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
} else {
#ifdef QT3_SUPPORT
if (d->asciiCache) {
+ QMutexLocker locker(asciiCacheMutex());
Q_ASSERT(asciiCache);
asciiCache->remove(d);
}