Commit a0d5aaf1 authored by Volker Krause's avatar Volker Krause
Browse files

Port away from QTextStream::setCodec

That is gone in Qt 6. Instead, manually iterate over the file and feed
it through the text codec.
parent 8a664461
Pipeline #260701 passed with stage
in 1 minute and 49 seconds
......@@ -593,15 +593,17 @@ QString KompareModelList::readFile(const QString& fileName)
QFile file(fileName);
file.open(QIODevice::ReadOnly);
QTextStream stream(&file);
qCDebug(LIBKOMPAREDIFF2) << "Codec = " << m_textCodec;
if (!m_textCodec)
m_textCodec = QTextCodec::codecForLocale();
std::unique_ptr<QTextDecoder> decoder(m_textCodec->makeDecoder());
stream.setCodec(m_textCodec);
QString contents = stream.readAll();
QString contents;
while (!file.atEnd()) {
char buffer[4096];
const auto len = file.read(buffer, 4096);
contents += decoder->toUnicode(buffer, len);
}
file.close();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment