summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs/qtextcodec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/codecs/qtextcodec.cpp')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 72f9dcc0a8a..be585d04070 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -53,7 +53,6 @@
#if !defined(QT_BOOTSTRAPPED)
#include <private/qcoreapplication_p.h>
#endif
-#include "private/qcoreglobaldata_p.h"
#include "qutfcodec_p.h"
#include "qlatincodec_p.h"
@@ -103,6 +102,28 @@ typedef QList<QByteArray>::ConstIterator ByteArrayListConstIt;
Q_GLOBAL_STATIC(QRecursiveMutex, textCodecsMutex);
+Q_GLOBAL_STATIC(QTextCodecData, textCodecData)
+
+QTextCodecData::QTextCodecData()
+ : codecForLocale(nullptr)
+{
+}
+
+QTextCodecData::~QTextCodecData()
+{
+ codecForLocale = nullptr;
+ QList<QTextCodec *> tmp = allCodecs;
+ allCodecs.clear();
+ codecCache.clear();
+ for (QList<QTextCodec *>::const_iterator it = tmp.constBegin(); it != tmp.constEnd(); ++it)
+ delete *it;
+}
+
+QTextCodecData *QTextCodecData::instance()
+{
+ return textCodecData();
+}
+
class TextCodecsMutexLocker
{
using Lock = decltype(qt_unique_lock(std::declval<QRecursiveMutex&>()));
@@ -166,7 +187,7 @@ static void setup();
// setCodecForLocale(0) is called at the same time.
static QTextCodec *setupLocaleMapper()
{
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ QTextCodecData *globalData = QTextCodecData::instance();
QTextCodec *locale = nullptr;
@@ -477,7 +498,7 @@ QTextCodec::QTextCodec()
{
const TextCodecsMutexLocker locker;
- QCoreGlobalData *globalInstance = QCoreGlobalData::instance();
+ QTextCodecData *globalInstance = QTextCodecData::instance();
if (globalInstance->allCodecs.isEmpty())
setup();
@@ -493,7 +514,7 @@ QTextCodec::QTextCodec()
*/
QTextCodec::~QTextCodec()
{
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ QTextCodecData *globalData = QTextCodecData::instance();
if (!globalData)
return;
@@ -534,7 +555,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
const TextCodecsMutexLocker locker;
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ QTextCodecData *globalData = QTextCodecData::instance();
if (!globalData)
return nullptr;
setup();
@@ -578,7 +599,7 @@ QTextCodec* QTextCodec::codecForMib(int mib)
{
const TextCodecsMutexLocker locker;
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ QTextCodecData *globalData = QTextCodecData::instance();
if (!globalData)
return nullptr;
if (globalData->allCodecs.isEmpty())
@@ -624,7 +645,7 @@ QList<QByteArray> QTextCodec::availableCodecs()
{
const TextCodecsMutexLocker locker;
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ QTextCodecData *globalData = QTextCodecData::instance();
if (globalData->allCodecs.isEmpty())
setup();
@@ -656,7 +677,7 @@ QList<int> QTextCodec::availableMibs()
#else
const TextCodecsMutexLocker locker;
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ QTextCodecData *globalData = QTextCodecData::instance();
if (globalData->allCodecs.isEmpty())
setup();
@@ -683,7 +704,7 @@ QList<int> QTextCodec::availableMibs()
*/
void QTextCodec::setCodecForLocale(QTextCodec *c)
{
- QCoreGlobalData::instance()->codecForLocale.storeRelease(c);
+ QTextCodecData::instance()->codecForLocale.storeRelease(c);
}
/*!
@@ -697,7 +718,7 @@ void QTextCodec::setCodecForLocale(QTextCodec *c)
QTextCodec* QTextCodec::codecForLocale()
{
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ QTextCodecData *globalData = QTextCodecData::instance();
if (!globalData)
return nullptr;