QmakeNodes: Fix renaming of files

We need to re-parse the file after removing the old filename. Otherwise
we only hit the right spot by accident when adding the new filename.

Task-number: QTCREATORBUG-15241
Change-Id: I2e72da9f14033cc757a8b51d2ce1f5c2a5e5b557
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-10-27 18:08:39 +01:00
parent 0d849b9f29
commit 1323956f59

View File

@@ -1267,10 +1267,16 @@ bool QmakePriFileNode::renameFile(const QString &oldName,
QDir priFileDir = QDir(m_qmakeProFileNode->m_projectDir);
QStringList notChanged = ProWriter::removeFiles(includeFile, &lines, priFileDir,
QStringList(oldName), varNamesForRemoving());
if (!notChanged.isEmpty()) {
includeFile->deref();
includeFile->deref();
if (!notChanged.isEmpty())
return false;
}
// We need to re-parse here: The file has changed.
QMakeParser parser(0, 0, 0);
includeFile = parser.parsedProBlock(lines.join(QLatin1Char('\n')),
m_projectFilePath.toString(), 1, QMakeParser::FullGrammar);
QTC_ASSERT(includeFile, return false); // The file should still be valid after what we did.
ProWriter::addFiles(includeFile, &lines,
QStringList(newName),