summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs/qiconvcodec.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-04-16 12:56:58 +0200
committerLars Knoll <lars.knoll@qt.io>2020-05-10 11:31:50 +0200
commitbabcabfbc899d5a72b282f8cf0b510840e91ba0e (patch)
treed4e89b175401d8daa0ca83675ab6b2f24de109e7 /src/corelib/codecs/qiconvcodec.cpp
parenta77b19a911c4d6c47c185a8e59ebbcec8b14bcca (diff)
Clean up state handling for ICU and iconv based codecs
Get rid of the hack for the FreeFunction and instead add a proper function pointer to clear the data to the ConverterState struct. Change-Id: I104aae1a4381c69f1a254713ec76e1aeaa862cdc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/codecs/qiconvcodec.cpp')
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index 9c39727946c..0fa18eadba7 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -121,7 +121,7 @@ void QIconvCodec::IconvState::saveChars(const char *c, int count)
static void qIconvCodecStateFree(QTextCodec::ConverterState *state)
{
- delete reinterpret_cast<QIconvCodec::IconvState *>(state->d);
+ delete reinterpret_cast<QIconvCodec::IconvState *>(state->d[0]);
}
Q_GLOBAL_STATIC(QThreadStorage<QIconvCodec::IconvState *>, toUnicodeState)
@@ -139,15 +139,14 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
if (convState) {
// stateful conversion
- pstate = reinterpret_cast<IconvState **>(&convState->d);
- if (convState->d) {
+ pstate = reinterpret_cast<IconvState **>(&convState->d[0]);
+ if (convState->d[0]) {
// restore state
remainingCount = convState->remainingChars;
remainingBuffer = (*pstate)->buffer;
} else {
// first time
- convState->flags |= FreeFunction;
- QTextCodecUnalignedPointer::encode(convState->state_data, qIconvCodecStateFree);
+ convState->clearFn = qIconvCodecStateFree;
}
} else {
QThreadStorage<QIconvCodec::IconvState *> *ts = toUnicodeState();