fake the system codec name

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-06-24 18:02:14 +03:00
parent 42413708fd
commit c382b404ce
2 changed files with 12 additions and 0 deletions

View file

@ -1021,8 +1021,15 @@ QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length,
}
#ifndef QT_NO_TEXTCODEC
extern QTextCodec* qt_localeMapper();
QByteArray QIcuCodec::name() const
{
if (qt_localeMapper() == this) {
// fake the name so that when it is saved in configuration files for example it is dynmaic
// instead of being saved as UTF-8 and the next time it is requested it will again resolve
// to the system codec
return QByteArray("System");
}
return m_name;
}

View file

@ -64,6 +64,11 @@ QTextCodec *QTextCodec::cftr = Q_NULLPTR;
Q_GLOBAL_STATIC(QMutex, textCodecsMutex)
#endif
QTextCodec* qt_localeMapper()
{
return localeMapper;
}
class QTextCodecCleanup : public QList<QTextCodec*>
{
public: