aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-04-03 08:12:52 +0200
committerEike Ziller <eike.ziller@qt.io>2020-04-03 08:12:52 +0200
commit897abf24e25d681c20a6fbbc03a6125b8d30cf3a (patch)
tree1fbb2ad420e8dcac89ff8cef6fc265b6797a2239 /src/shared
parent4880694df46b83bff55840d47c056356b9e73ac5 (diff)
parent708f84cce8f1a0d35c5a438c9dcc240b6e840a6d (diff)
Merge remote-tracking branch 'origin/4.12'
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/proparser/prowriter.cpp9
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;