From babcabfbc899d5a72b282f8cf0b510840e91ba0e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 16 Apr 2020 12:56:58 +0200 Subject: 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 --- src/corelib/codecs/qiconvcodec.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/corelib/codecs/qiconvcodec.cpp') 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(state->d); + delete reinterpret_cast(state->d[0]); } Q_GLOBAL_STATIC(QThreadStorage, toUnicodeState) @@ -139,15 +139,14 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState if (convState) { // stateful conversion - pstate = reinterpret_cast(&convState->d); - if (convState->d) { + pstate = reinterpret_cast(&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 *ts = toUnicodeState(); -- cgit v1.2.3