From 3211fd1e439d1e94cb09698f09ad81df88e36d18 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 12 Dec 2023 14:05:10 +0100 Subject: [PATCH] GitClient: Make lambda non-mutable Do a copy of future interface inside the lambda body instead. Change-Id: If84e37c62e43b815cfea0b5f60fe7fcebca63093 Reviewed-by: Orgad Shaneh --- src/plugins/git/gitclient.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 508b1d4b81f..dca467c632a 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -3458,12 +3458,13 @@ QFuture GitClient::gitVersion() const const bool needToRunGit = m_gitVersionForBinary != newGitBinary && !newGitBinary.isEmpty(); if (needToRunGit) { auto proc = new Process(const_cast(this)); - connect(proc, &Process::done, this, [this, proc, fi, newGitBinary]() mutable { + connect(proc, &Process::done, this, [this, proc, fi, newGitBinary] { + auto fiCopy = fi; // In order to avoid mutable lambda. if (proc->result() == ProcessResult::FinishedWithSuccess) { m_cachedGitVersion = parseGitVersion(proc->cleanedStdOut()); m_gitVersionForBinary = newGitBinary; - fi.reportResult(m_cachedGitVersion); - fi.reportFinished(); + fiCopy.reportResult(m_cachedGitVersion); + fiCopy.reportFinished(); } proc->deleteLater(); });