summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/sparc/arch.pri2
-rw-r--r--src/corelib/codecs/qsimplecodec.cpp2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp46
-rw-r--r--src/corelib/global/qglobal.cpp2
-rw-r--r--src/corelib/global/qglobal.h3
5 files changed, 40 insertions, 15 deletions
diff --git a/src/corelib/arch/sparc/arch.pri b/src/corelib/arch/sparc/arch.pri
index 3113dd3..9bb3a88 100644
--- a/src/corelib/arch/sparc/arch.pri
+++ b/src/corelib/arch/sparc/arch.pri
@@ -1,7 +1,7 @@
#
# SPARC architecture
#
-*-64 {
+*-64* {
SOURCES += $$QT_ARCH_CPP/qatomic64.s
}
else {
diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp
index 445565a..4cc7912 100644
--- a/src/corelib/codecs/qsimplecodec.cpp
+++ b/src/corelib/codecs/qsimplecodec.cpp
@@ -681,7 +681,7 @@ QByteArray QSimpleTextCodec::convertFromUnicode(const QChar *in, int length, Con
int u;
const QChar* ucp = in;
unsigned char* rp = (unsigned char *)r.data();
- const unsigned char* rmp = (const unsigned char *)reverseMap->data();
+ const unsigned char* rmp = (const unsigned char *)reverseMap->constData();
int rmsize = (int) reverseMap->size();
while(i--)
{
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 43ea1c8..1c607a6 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -79,7 +79,7 @@
# endif
#endif // QT_NO_CODECS
#include "qlocale.h"
-#include "private/qmutexpool_p.h"
+#include "qmutex.h"
#include <stdlib.h>
#include <ctype.h>
@@ -659,13 +659,13 @@ static void setupLocaleMapper()
#endif
}
-
-static void setup()
-{
#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&all));
+Q_GLOBAL_STATIC_WITH_ARGS(QMutex, textCodecsMutex, (QMutex::Recursive));
#endif
+// textCodecsMutex need to be locked to enter this function
+static void setup()
+{
if (all)
return;
@@ -903,8 +903,6 @@ QTextCodec::ConverterState::~ConverterState()
*/
/*!
- \nonreentrant
-
Constructs a QTextCodec, and gives it the highest precedence. The
QTextCodec should always be constructed on the heap (i.e. with \c
new). Qt takes ownership and will delete it when the application
@@ -912,6 +910,9 @@ QTextCodec::ConverterState::~ConverterState()
*/
QTextCodec::QTextCodec()
{
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(textCodecsMutex());
+#endif
setup();
all->prepend(this);
}
@@ -929,8 +930,12 @@ QTextCodec::~QTextCodec()
if (!destroying_is_ok)
qWarning("QTextCodec::~QTextCodec: Called by application");
#endif
- if (all)
+ if (all) {
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(textCodecsMutex());
+#endif
all->removeAll(this);
+ }
}
/*!
@@ -951,6 +956,9 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
if (name.isEmpty())
return 0;
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(textCodecsMutex());
+#endif
setup();
for (int i = 0; i < all->size(); ++i) {
@@ -973,6 +981,9 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
*/
QTextCodec* QTextCodec::codecForMib(int mib)
{
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(textCodecsMutex());
+#endif
setup();
// Qt 3 used 1000 (mib for UCS2) as its identifier for the utf16 codec. Map
@@ -1001,6 +1012,9 @@ QTextCodec* QTextCodec::codecForMib(int mib)
*/
QList<QByteArray> QTextCodec::availableCodecs()
{
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(textCodecsMutex());
+#endif
setup();
QList<QByteArray> codecs;
@@ -1008,6 +1022,11 @@ QList<QByteArray> QTextCodec::availableCodecs()
codecs += all->at(i)->name();
codecs += all->at(i)->aliases();
}
+
+#ifndef QT_NO_THREAD
+ locker.unlock();
+#endif
+
#ifndef QT_NO_TEXTCODECPLUGIN
QFactoryLoader *l = loader();
QStringList keys = l->keys();
@@ -1031,11 +1050,19 @@ QList<QByteArray> QTextCodec::availableCodecs()
*/
QList<int> QTextCodec::availableMibs()
{
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(textCodecsMutex());
+#endif
setup();
QList<int> codecs;
for (int i = 0; i < all->size(); ++i)
codecs += all->at(i)->mibEnum();
+
+#ifndef QT_NO_THREAD
+ locker.unlock();
+#endif
+
#ifndef QT_NO_TEXTCODECPLUGIN
QFactoryLoader *l = loader();
QStringList keys = l->keys();
@@ -1082,6 +1109,9 @@ QTextCodec* QTextCodec::codecForLocale()
if (localeMapper)
return localeMapper;
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(textCodecsMutex());
+#endif
setup();
return localeMapper;
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index f48c1b3..c8f836a 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1994,7 +1994,6 @@ void qt_check_pointer(const char *n, int l)
qWarning("In file %s, line %d: Out of memory", n, l);
}
-#ifndef QT_NO_EXCEPTIONS
/* \internal
Allows you to throw an exception without including <new>
Called internally from Q_CHECK_PTR on certain OS combinations
@@ -2003,7 +2002,6 @@ void qBadAlloc()
{
QT_THROW(std::bad_alloc());
}
-#endif
/*
The Q_ASSERT macro calls this function when the test fails.
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index b237659..99bbe42 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1676,10 +1676,7 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *
#endif
Q_CORE_EXPORT void qt_check_pointer(const char *, int);
-
-#ifndef QT_NO_EXCEPTIONS
Q_CORE_EXPORT void qBadAlloc();
-#endif
#ifdef QT_NO_EXCEPTIONS
# if defined(QT_NO_DEBUG)