forked from qt-creator/qt-creator
CMake: Make fileapi not race against its own reply file detection
Fix broken logic to prevent CMake fileapi from detecting the change its own cmake run triggered via file watching. Remember the last file that was parsed and do not attempt to parse this again. Remember the file on a per-project basis, too:-) Change-Id: Ia6e155b65d77994f6e3d2a3677f770a4ba53539d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
committed by
Alexandru Croitor
parent
ec92784778
commit
eab0df22f9
@@ -60,16 +60,6 @@ static void reportFileApiSetupFailure()
|
||||
"Failed to set up cmake fileapi support. Creator can not extract project information."));
|
||||
}
|
||||
|
||||
static bool shouldProcessFile(const QString &filePath, bool update = true)
|
||||
{
|
||||
static QString lastSeenFilePath;
|
||||
if (filePath == lastSeenFilePath)
|
||||
return false;
|
||||
if (update)
|
||||
lastSeenFilePath = filePath;
|
||||
return true;
|
||||
}
|
||||
|
||||
static std::pair<int, int> cmakeVersion(const QJsonObject &obj)
|
||||
{
|
||||
const QJsonObject version = obj.value("version").toObject();
|
||||
@@ -946,11 +936,16 @@ QStringList FileApiParser::cmakeQueryFilePaths() const
|
||||
[&queryDir](const QString &name) { return queryDir.absoluteFilePath(name); });
|
||||
}
|
||||
|
||||
void FileApiParser::setParsedReplyFilePath(const QString &filePath)
|
||||
{
|
||||
m_lastParsedReplyFile = filePath;
|
||||
}
|
||||
|
||||
void FileApiParser::replyDirectoryHasChanged(const QString &directory) const
|
||||
{
|
||||
if (directory == cmakeReplyDirectory().toString()) {
|
||||
QFileInfo fi = scanForCMakeReplyFile();
|
||||
if (fi.isFile() && shouldProcessFile(fi.filePath(), false)) {
|
||||
if (fi.isFile() && fi.filePath() != m_lastParsedReplyFile) {
|
||||
emit dirty();
|
||||
}
|
||||
}
|
||||
|
@@ -251,6 +251,8 @@ public:
|
||||
QStringList cmakeQueryFileNames() const;
|
||||
QStringList cmakeQueryFilePaths() const;
|
||||
|
||||
void setParsedReplyFilePath(const QString &filePath);
|
||||
|
||||
static FileApiData parseData(const QFileInfo &replyFileInfo, QString &errorMessage);
|
||||
|
||||
signals:
|
||||
@@ -266,6 +268,7 @@ private:
|
||||
|
||||
void replyDirectoryHasChanged(const QString &directory) const;
|
||||
Utils::FileSystemWatcher m_watcher;
|
||||
QString m_lastParsedReplyFile;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -231,6 +231,8 @@ void FileApiReader::endState(const QFileInfo &replyFi)
|
||||
const FilePath sourceDirectory = m_parameters.sourceDirectory;
|
||||
const FilePath buildDirectory = m_parameters.workDirectory;
|
||||
|
||||
m_fileApi->setParsedReplyFilePath(replyFi.filePath());
|
||||
|
||||
m_future = runAsync(ProjectExplorerPlugin::sharedThreadPool(),
|
||||
[replyFi, sourceDirectory, buildDirectory]() {
|
||||
auto result = std::make_unique<FileApiQtcData>();
|
||||
|
Reference in New Issue
Block a user