mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
verify codec is provided by ICU codec before attempting to create it
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
e9622b5dd4
commit
7a7f5173cd
1 changed files with 13 additions and 1 deletions
|
@ -105,6 +105,8 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test)
|
|||
return (*h == '\0');
|
||||
}
|
||||
|
||||
static QList<QByteArray> icucodecs;
|
||||
|
||||
static QTextCodec *createForName(const QByteArray &name)
|
||||
{
|
||||
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_TEXTCODECPLUGIN)
|
||||
|
@ -123,7 +125,17 @@ static QTextCodec *createForName(const QByteArray &name)
|
|||
Q_UNUSED(name);
|
||||
#endif
|
||||
|
||||
return new QIcuCodec(name.constData());
|
||||
if (icucodecs.isEmpty()) {
|
||||
icucodecs = QIcuCodec::availableCodecs();
|
||||
}
|
||||
|
||||
foreach(const QByteArray codec, icucodecs) {
|
||||
if (nameMatch(name, codec)) {
|
||||
return new QIcuCodec(name.constData());
|
||||
}
|
||||
}
|
||||
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
static QTextCodec *createForMib(int mib)
|
||||
|
|
Loading…
Add table
Reference in a new issue