Skip to content

Commit

Permalink
ConfigObject: guard QTextStream::setCodec behind Qt version check
Browse files Browse the repository at this point in the history
QTextSTream::setCodec was removed in Qt6:
https://bugreports.qt.io/browse/QTBUG-75665
  • Loading branch information
Be-ing committed Oct 13, 2021
1 parent 0a94d35 commit 5102c9b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/preferences/configobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ template <class ValueType> bool ConfigObject<ValueType>::parse() {
int group = 0;
QString groupStr, line;
QTextStream text(&configfile);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
DEBUG_ASSERT(out.encoding() == QStringConverter::Utf8);
#else
text.setCodec("UTF-8");
#endif

while (!text.atEnd()) {
line = text.readLine().trimmed();
Expand Down Expand Up @@ -213,7 +217,10 @@ bool ConfigObject<ValueType>::save() {
return false;
}
QTextStream stream(&tmpFile);
// UTF-8 is the default in Qt6.
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8");
#endif

QString group = "";

Expand Down

0 comments on commit 5102c9b

Please sign in to comment.