diff options
author | Eike Ziller <eike.ziller@qt.io> | 2020-04-03 08:12:52 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2020-04-03 08:12:52 +0200 |
commit | 897abf24e25d681c20a6fbbc03a6125b8d30cf3a (patch) | |
tree | 1fbb2ad420e8dcac89ff8cef6fc265b6797a2239 /src/shared | |
parent | 4880694df46b83bff55840d47c056356b9e73ac5 (diff) | |
parent | 708f84cce8f1a0d35c5a438c9dcc240b6e840a6d (diff) |
Merge remote-tracking branch 'origin/4.12'
Change-Id: I79083060dfc3bc4408123acd3b7305b9701650fd
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/proparser/prowriter.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shared/proparser/prowriter.cpp b/src/shared/proparser/prowriter.cpp index 52d49751f2..e3fcc5f600 100644 --- a/src/shared/proparser/prowriter.cpp +++ b/src/shared/proparser/prowriter.cpp @@ -471,12 +471,17 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines, // This code expects proVars to be sorted by the variables' appearance in the file. int delta = 1; - for (const VarLocation &loc : qAsConst(varLocations)) { + for (int varIndex = 0; varIndex < varLocations.count(); ++varIndex) { + const VarLocation &loc = varLocations[varIndex]; bool first = true; int lineNo = loc.second - delta; typedef QPair<int, int> ContPos; QList<ContPos> contPos; - while (lineNo < lines->count()) { + const auto nextSegmentStart = [varIndex, lines, &delta, &varLocations] { + return varIndex == varLocations.count() - 1 + ? lines->count() : varLocations[varIndex + 1].second - delta; + }; + while (lineNo < nextSegmentStart()) { QString &line = (*lines)[lineNo]; int lineLen = line.length(); bool killed = false; |