diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-07-20 10:00:52 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-31 11:11:43 +0200 |
commit | 5af9ecafd9c14f39bec5fed3192a266ec9e31ffe (patch) | |
tree | 5b057af18521a688f99ccde68f214a9cca492f6f /src/corelib/kernel | |
parent | 920dcb0158e191f0eadf4bec0645348cfb6e9619 (diff) |
Move the text codec list to qcoreglobaldata.
This removes some global statics in QTextCodec and
makes the code better to maintain in the longer term.
Remove QT_NO_THREAD defines around mutexes as this
isn't required in Qt 5 anymore.
Change-Id: I15ede75f53b16f134f4053f3188c4b47e86fcd8a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcoreglobaldata.cpp | 13 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreglobaldata_p.h | 12 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreglobaldata.cpp b/src/corelib/kernel/qcoreglobaldata.cpp index d8ffcaae48..7d06f0e392 100644 --- a/src/corelib/kernel/qcoreglobaldata.cpp +++ b/src/corelib/kernel/qcoreglobaldata.cpp @@ -40,11 +40,24 @@ ****************************************************************************/ #include "qcoreglobaldata_p.h" +#include "qtextcodec.h" QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QCoreGlobalData, globalInstance) +QCoreGlobalData::QCoreGlobalData() + : codecForLocale(0) +{ +} + +QCoreGlobalData::~QCoreGlobalData() +{ + codecForLocale = 0; + for (QList<QTextCodec *>::const_iterator it = allCodecs.constBegin(); it != allCodecs.constEnd(); ++it) + delete *it; +} + QCoreGlobalData *QCoreGlobalData::instance() { return globalInstance(); diff --git a/src/corelib/kernel/qcoreglobaldata_p.h b/src/corelib/kernel/qcoreglobaldata_p.h index 50f619acf5..39281aa6e8 100644 --- a/src/corelib/kernel/qcoreglobaldata_p.h +++ b/src/corelib/kernel/qcoreglobaldata_p.h @@ -56,13 +56,25 @@ #include "QtCore/qmap.h" #include "QtCore/qstringlist.h" #include "QtCore/qreadwritelock.h" +#include "QtCore/qhash.h" +#include "QtCore/qbytearray.h" +#include "QtCore/qtextcodec.h" QT_BEGIN_NAMESPACE +typedef QHash<QByteArray, QTextCodec *> QTextCodecCache; + struct QCoreGlobalData { + QCoreGlobalData(); + ~QCoreGlobalData(); + QMap<QString, QStringList> dirSearchPaths; QReadWriteLock dirSearchPathsLock; + QList<QTextCodec*> allCodecs; + QTextCodec *codecForLocale; + QTextCodecCache codecCache; + static QCoreGlobalData *instance(); }; |