CMakeManager: Simplify mutable lambda

Make lambda non-mutable. Pass CMakeManager as a context object
into the connection.

Amends ed1568309b

Change-Id: I022a8c468374eaf694acd7d8dbab0579c37bd8df
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Jarek Kobus
2023-12-12 12:49:19 +01:00
parent 5117ca3280
commit afd979a6d9

View File

@@ -215,25 +215,18 @@ void CMakeManager::runCMakeWithProfiling(BuildSystem *buildSystem)
if (ProjectExplorerPlugin::saveModifiedFiles()) {
// cmakeBuildSystem->runCMakeWithProfiling() below will trigger Target::buildSystemUpdated
// which will ensure that the "cmake-profile.json" has been created and we can load the viewer
std::unique_ptr<QObject> context{new QObject};
QObject *pcontext = context.get();
QObject::connect(cmakeBuildSystem->target(),
&Target::buildSystemUpdated,
pcontext,
[context = std::move(context)]() mutable {
context.reset();
Core::Command *ctfVisualiserLoadTrace = Core::ActionManager::command(
"Analyzer.Menu.StartAnalyzer.CtfVisualizer.LoadTrace");
QObject::connect(cmakeBuildSystem->target(), &Target::buildSystemUpdated, this, [] {
Core::Command *ctfVisualiserLoadTrace = Core::ActionManager::command(
"Analyzer.Menu.StartAnalyzer.CtfVisualizer.LoadTrace");
if (ctfVisualiserLoadTrace) {
auto *action = ctfVisualiserLoadTrace->actionForContext(
Core::Constants::C_GLOBAL);
const FilePath file = TemporaryDirectory::masterDirectoryFilePath()
/ "cmake-profile.json";
action->setData(file.nativePath());
emit ctfVisualiserLoadTrace->action()->triggered();
}
});
if (ctfVisualiserLoadTrace) {
auto *action = ctfVisualiserLoadTrace->actionForContext(Core::Constants::C_GLOBAL);
const FilePath file = TemporaryDirectory::masterDirectoryFilePath()
/ "cmake-profile.json";
action->setData(file.nativePath());
emit ctfVisualiserLoadTrace->action()->triggered();
}
});
cmakeBuildSystem->runCMakeWithProfiling();
}