Skip to content

Commit

Permalink
Merge pull request #4399 from Be-ing/configobject_setcodec
Browse files Browse the repository at this point in the history
ConfigObject: guard QTextStream::setCodec behind Qt version check
  • Loading branch information
uklotzde authored Oct 13, 2021
2 parents 778edbf + efa0417 commit 8bdaae6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 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(text.encoding() == QStringConverter::Utf8);
#else
text.setCodec("UTF-8");
#endif

while (!text.atEnd()) {
line = text.readLine().trimmed();
Expand Down Expand Up @@ -213,7 +217,12 @@ 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)
DEBUG_ASSERT(stream.encoding() == QStringConverter::Utf8);
#else
stream.setCodec("UTF-8");
#endif

QString group = "";

Expand Down

0 comments on commit 8bdaae6

Please sign in to comment.