QmlProjectManager: Use proper method to get qmlproject files for MCU

This patch replaces the blind traversing in the project root to find
and parse the additional qmlproject files which are used by MCU
projects. Instead it's now using the qmlProjectModules() function to
reliably get the valid ones for the MCU projects.

Task-number: QDS-13068
Change-Id: I4e5e1791714345b69c0b2ac7929ae39c30521224
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
This commit is contained in:
Burak Hancerli
2024-06-26 15:27:14 +02:00
parent da1c00ca64
commit 827ace5c9e

View File

@@ -237,38 +237,28 @@ void QmlBuildSystem::initMcuProjectItems()
m_mcuProjectItems.clear();
m_mcuProjectFilesWatcher.clear();
Utils::FilePath projectDir = projectFilePath().parentDir();
// traverse the project dir and find all other mcu projects (.qmlproject files) in the project tree
// and add them to the m_mcuProjectItems vector
QDirIterator it(projectDir.toFSPathString(), QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
it.next();
if (it.fileInfo().suffix() == "qmlproject" && it.filePath() != projectFilePath().toString()) {
auto qmlProjectItem = QSharedPointer<QmlProjectItem>(
new QmlProjectItem{Utils::FilePath::fromString(it.filePath())});
const QStringList mcuProjectFiles = m_projectItem->qmlProjectModules();
for (const QString &mcuProjectFile : mcuProjectFiles) {
auto qmlProjectItem = QSharedPointer<QmlProjectItem>(
new QmlProjectItem{Utils::FilePath::fromString(mcuProjectFile)});
m_mcuProjectItems.append(qmlProjectItem);
connect(qmlProjectItem.data(),
&QmlProjectItem::filesChanged,
this,
&QmlBuildSystem::refreshFiles);
connect(qmlProjectItem.data(),
&QmlProjectItem::filesChanged,
m_cmakeGen,
&GenerateCmake::CMakeGenerator::update);
m_mcuProjectItems.append(qmlProjectItem);
connect(qmlProjectItem.data(), &QmlProjectItem::filesChanged, this, &QmlBuildSystem::refreshFiles);
connect(qmlProjectItem.data(),
&QmlProjectItem::filesChanged,
m_cmakeGen,
&GenerateCmake::CMakeGenerator::update);
m_mcuProjectFilesWatcher.addFile(it.filePath(),
Utils::FileSystemWatcher::WatchModifiedDate);
m_mcuProjectFilesWatcher.addFile(mcuProjectFile, Utils::FileSystemWatcher::WatchModifiedDate);
connect(&m_mcuProjectFilesWatcher,
&Utils::FileSystemWatcher::fileChanged,
this,
[this](const QString &file) {
Q_UNUSED(file)
initMcuProjectItems();
refresh(RefreshOptions::Files);
});
}
connect(&m_mcuProjectFilesWatcher,
&Utils::FileSystemWatcher::fileChanged,
this,
[this](const QString &file) {
Q_UNUSED(file)
initMcuProjectItems();
refresh(RefreshOptions::Files);
});
}
}