logic: fixed crash when specifying an unknown text encoding in appsettings

* also: updated jar dependencies
This commit is contained in:
mlangkabel
2017-11-17 13:03:05 +01:00
parent 9d17e2e7e6
commit 634601b4b6
3 changed files with 18 additions and 10 deletions
+14 -6
View File
@@ -49,14 +49,22 @@ QtCodeField::QtCodeField(
}
QTextCodec* codec = QTextCodec::codecForName(ApplicationSettings::getInstance()->getTextEncoding().c_str());
QString convertedDisplayCode(codec->toUnicode(displayCode.c_str()));
setPlainText(convertedDisplayCode);
createLineLengthCache();
if (displayCode.size() != convertedDisplayCode.length())
if (codec)
{
LOG_INFO("Converting displayed code to " + codec->name().toStdString() + " resulted in offset of source locations. Correcting this now.");
createMultibyteCharacterLocationCache();
QString convertedDisplayCode(codec->toUnicode(displayCode.c_str()));
setPlainText(convertedDisplayCode);
if (displayCode.size() != convertedDisplayCode.length())
{
LOG_INFO("Converting displayed code to " + codec->name().toStdString() + " resulted in offset of source locations. Correcting this now.");
createMultibyteCharacterLocationCache();
}
}
else
{
setPlainText(displayCode.c_str());
}
createLineLengthCache();
this->setMouseTracking(true);