forked from qt-creator/qt-creator
ProWriter: Fix removeVarValues() function
This function wrongly assumed that there is always an empty line between variable assignments. For instance, When renaming a header file in a project file where HEADERS follows right after SOURCES, the function would erroneously claim that it removed the header file from the SOURCES segment, so follow-up code added the name name there instead of to HEADERS. Fixes: QTCREATORBUG-23720 Change-Id: I55288b22fe16fa0593b277d8808ab5d64ba90549 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user