MesonProjectManager: fix loading previously configured projects

File watcher was not looking in build dir and wasn't updated when build
directory changed.
Also parsing should only happen on active build configurations.

Task-number: QTCREATORBUG-33071
Change-Id: I0c1ce95729472a7c08e029a322b7213acfe9c2f1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alexis Jeandet
2025-06-17 12:19:59 +02:00
parent dd68dd90d3
commit 54a0c74ff8
2 changed files with 23 additions and 12 deletions

View File

@@ -206,10 +206,8 @@ MesonBuildSystem::MesonBuildSystem(BuildConfiguration *bc)
connect(bc, &BuildConfiguration::kitChanged, this, [this] {
updateKit(kit());
});
connect(bc, &MesonBuildConfiguration::buildDirectoryChanged, this, [this] {
updateKit(kit());
this->triggerParsing();
});
connect(bc, &MesonBuildConfiguration::buildDirectoryChanged, this,
&MesonBuildSystem::buildDirectoryChanged);
connect(qobject_cast<MesonBuildConfiguration *>(bc),
&MesonBuildConfiguration::parametersChanged, this, [this] {
updateKit(kit());
@@ -231,14 +229,6 @@ MesonBuildSystem::MesonBuildSystem(BuildConfiguration *bc)
});
updateKit(kit());
// as specified here https://mesonbuild.com/IDE-integration.html#ide-integration
// meson-info.json is the last written file, which ensure that all others introspection
// files are ready when a modification is detected on this one.
m_IntroWatcher.addFile(buildConfiguration()
->buildDirectory()
.pathAppended(Constants::MESON_INFO_DIR)
.pathAppended(Constants::MESON_INFO),
Utils::FileSystemWatcher::WatchModifiedDate);
}
MesonBuildSystem::~MesonBuildSystem()
@@ -296,6 +286,24 @@ QStringList MesonBuildSystem::configArgs(bool isSetup)
+ m_pendingConfigArgs + bc->mesonConfigArgs();
}
void MesonBuildSystem::buildDirectoryChanged()
{
updateKit(kit());
m_IntroWatcher.clear();
if (buildConfiguration()->isActive())
{
// as specified here https://mesonbuild.com/IDE-integration.html#ide-integration
// meson-info.json is the last written file, which ensure that all others introspection
// files are ready when a modification is detected on this one.
m_IntroWatcher.addFile(buildConfiguration()
->buildDirectory()
.pathAppended(Constants::MESON_INFO_DIR)
.pathAppended(Constants::MESON_INFO),
Utils::FileSystemWatcher::WatchModifiedDate);
}
this->triggerParsing();
}
bool MesonBuildSystem::configure()
{
LEAVE_IF_BUSY();
@@ -337,6 +345,8 @@ bool MesonBuildSystem::wipe()
bool MesonBuildSystem::parseProject()
{
QTC_ASSERT(buildConfiguration(), return false);
if (!buildConfiguration()->isActive()) // Never parse if not active
return false;
if (!isSetup(buildConfiguration()->buildDirectory()) && settings().autorunMeson())
return configure();
LEAVE_IF_BUSY();

View File

@@ -42,6 +42,7 @@ private:
bool needsSetup();
void parsingCompleted(bool success);
QStringList configArgs(bool isSetup);
void buildDirectoryChanged();
ProjectExplorer::BuildSystem::ParseGuard m_parseGuard;
MesonProjectParser m_parser;