forked from qt-creator/qt-creator
qmake: Change source identifier type in ProString
The strings remember in which file they were created/assigned. However, this used a non-counting reference to a ProFile, which could become dangling. If a subsequent ProFile re-used the exact same address, a string's source would be mis-identified, which would be fatal in conjunction with discard_from(). Since we actually need only a unique id for comparison, let's use an integer for that. comment on cherry-pick: this is actually a lot more than a cherry-pick, because the file ids need to be aware of the dual VFS which was concurrently introduced on the qtc side. Started-by: Simon Hausmann <simon.hausmann@qt.io> Change-Id: I395153afaf7c835d0119690ee7f4b915e6f90d4a (cherry picked from qtbase/190aa94be7f5e146bef44862b974d733755cec85) Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -237,7 +237,8 @@ QmakePriFile::~QmakePriFile()
|
||||
|
||||
void QmakePriFile::scheduleUpdate()
|
||||
{
|
||||
QtSupport::ProFileCacheManager::instance()->discardFile(filePath().toString());
|
||||
QtSupport::ProFileCacheManager::instance()->discardFile(
|
||||
filePath().toString(), m_project->qmakeVfs());
|
||||
m_qmakeProFile->scheduleUpdate(QmakeProFile::ParseLater);
|
||||
}
|
||||
|
||||
@@ -292,11 +293,11 @@ static QStringList fileListForVar(
|
||||
}
|
||||
|
||||
void QmakePriFile::extractSources(
|
||||
QHash<const ProFile *, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
|
||||
QHash<int, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
|
||||
QVector<ProFileEvaluator::SourceFile> sourceFiles, FileType type)
|
||||
{
|
||||
foreach (const ProFileEvaluator::SourceFile &source, sourceFiles) {
|
||||
QmakePriFileEvalResult *result = proToResult.value(source.proFile);
|
||||
auto *result = proToResult.value(source.proFileId);
|
||||
if (!result)
|
||||
result = fallback;
|
||||
result->foundFiles[type].insert(FileName::fromString(source.fileName));
|
||||
@@ -304,12 +305,12 @@ void QmakePriFile::extractSources(
|
||||
}
|
||||
|
||||
void QmakePriFile::extractInstalls(
|
||||
QHash<const ProFile *, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
|
||||
QHash<int, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
|
||||
const InstallsList &installList)
|
||||
{
|
||||
for (const InstallsItem &item : installList.items) {
|
||||
for (const ProFileEvaluator::SourceFile &source : item.files) {
|
||||
auto *result = proToResult.value(source.proFile);
|
||||
auto *result = proToResult.value(source.proFileId);
|
||||
if (!result)
|
||||
result = fallback;
|
||||
result->folders.insert(FileName::fromString(source.fileName));
|
||||
@@ -621,7 +622,8 @@ bool QmakePriFile::saveModifiedEditors()
|
||||
return false;
|
||||
|
||||
// force instant reload of ourselves
|
||||
QtSupport::ProFileCacheManager::instance()->discardFile(filePath().toString());
|
||||
QtSupport::ProFileCacheManager::instance()->discardFile(
|
||||
filePath().toString(), m_project->qmakeVfs());
|
||||
QmakeProject::notifyChanged(filePath());
|
||||
return true;
|
||||
}
|
||||
@@ -701,7 +703,7 @@ QPair<ProFile *, QStringList> QmakePriFile::readProFile(const QString &file)
|
||||
QMakeVfs vfs;
|
||||
QtSupport::ProMessageHandler handler;
|
||||
QMakeParser parser(nullptr, &vfs, &handler);
|
||||
includeFile = parser.parsedProBlock(QStringRef(&contents), file, 1);
|
||||
includeFile = parser.parsedProBlock(QStringRef(&contents), 0, file, 1);
|
||||
}
|
||||
return qMakePair(includeFile, lines);
|
||||
}
|
||||
@@ -738,7 +740,7 @@ bool QmakePriFile::renameFile(const QString &oldName,
|
||||
QMakeParser parser(nullptr, nullptr, nullptr);
|
||||
QString contents = lines.join(QLatin1Char('\n'));
|
||||
includeFile = parser.parsedProBlock(QStringRef(&contents),
|
||||
filePath().toString(), 1, QMakeParser::FullGrammar);
|
||||
0, filePath().toString(), 1, QMakeParser::FullGrammar);
|
||||
QTC_ASSERT(includeFile, return false); // The file should still be valid after what we did.
|
||||
|
||||
ProWriter::addFiles(includeFile, &lines,
|
||||
@@ -1294,7 +1296,7 @@ QmakeEvalResult *QmakeProFile::evaluate(const QmakeEvalInput &input)
|
||||
result->includedFiles.proFile = pro;
|
||||
result->includedFiles.name = input.projectFilePath;
|
||||
|
||||
QHash<const ProFile *, QmakePriFileEvalResult *> proToResult;
|
||||
QHash<int, QmakePriFileEvalResult *> proToResult;
|
||||
|
||||
result->projectType
|
||||
= proFileTemplateTypeToProjectType(
|
||||
@@ -1332,7 +1334,7 @@ QmakeEvalResult *QmakeProFile::evaluate(const QmakeEvalInput &input)
|
||||
childTree->proFile = child;
|
||||
childTree->name = childName;
|
||||
current->children.insert(childName, childTree);
|
||||
proToResult[child] = &childTree->result;
|
||||
proToResult[child->id()] = &childTree->result;
|
||||
}
|
||||
}
|
||||
toBuild.append(current->children.values());
|
||||
@@ -1368,7 +1370,7 @@ QmakeEvalResult *QmakeProFile::evaluate(const QmakeEvalInput &input)
|
||||
childTree->proFile = child;
|
||||
childTree->name = childName;
|
||||
current->children.insert(childName, childTree);
|
||||
proToResult[child] = &childTree->result;
|
||||
proToResult[child->id()] = &childTree->result;
|
||||
}
|
||||
}
|
||||
toBuild.append(current->children.values());
|
||||
|
||||
Reference in New Issue
Block a user