GitClient: Make lambda non-mutable

Do a copy of future interface inside the lambda body instead.

Change-Id: If84e37c62e43b815cfea0b5f60fe7fcebca63093
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2023-12-12 14:05:10 +01:00
parent b60c438f34
commit 3211fd1e43

View File

@@ -3458,12 +3458,13 @@ QFuture<unsigned> GitClient::gitVersion() const
const bool needToRunGit = m_gitVersionForBinary != newGitBinary && !newGitBinary.isEmpty();
if (needToRunGit) {
auto proc = new Process(const_cast<GitClient *>(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();
});