From a6b17d127af250ae65566e121867071b55f9afe3 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 8 Dec 2022 14:43:50 +0100 Subject: [PATCH] VcsBase, Git: Don't use queued connections to VcsCommand Otherwise, the destructor of VcsCommand could have been executed in meantime (since it's invoked automatically after done()) and we might access invalid pointer to the command inside the done handler. Change-Id: I031e2281952451d4e01c47f437097a1e7bf8899f Reviewed-by: Orgad Shaneh Reviewed-by: --- src/plugins/git/gitclient.cpp | 6 +++--- src/plugins/vcsbase/vcsbaseclient.cpp | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index a13a23deaac..220d0de71ed 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -1108,8 +1108,8 @@ void GitClient::status(const FilePath &workingDirectory) const { VcsOutputWindow::setRepository(workingDirectory); VcsCommand *command = vcsExec(workingDirectory, {"status", "-u"}, nullptr, true); - connect(command, &VcsCommand::done, VcsOutputWindow::instance(), - &VcsOutputWindow::clearRepository, Qt::QueuedConnection); + connect(command, &VcsCommand::done, + VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository); } static QStringList normalLogArguments() @@ -3113,7 +3113,7 @@ void GitClient::pull(const FilePath &workingDirectory, bool rebase) connect(command, &VcsCommand::done, this, [this, workingDirectory, command] { if (command->result() == ProcessResult::FinishedWithSuccess) updateSubmodulesIfNeeded(workingDirectory, true); - }, Qt::QueuedConnection); + }); } void GitClient::synchronousAbortCommand(const FilePath &workingDir, const QString &abortCommand) diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 93e829b164d..15e7341c0fd 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -420,7 +420,7 @@ void VcsBaseClient::revertFile(const FilePath &workingDir, connect(cmd, &VcsCommand::done, this, [this, files, cmd] { if (cmd->result() == ProcessResult::FinishedWithSuccess) emit changed(files); - }, Qt::QueuedConnection); + }); enqueueJob(cmd, args); } @@ -436,7 +436,7 @@ void VcsBaseClient::revertAll(const FilePath &workingDir, connect(cmd, &VcsCommand::done, this, [this, files, cmd] { if (cmd->result() == ProcessResult::FinishedWithSuccess) emit changed(files); - }, Qt::QueuedConnection); + }); enqueueJob(createCommand(workingDir), args); } @@ -448,8 +448,7 @@ void VcsBaseClient::status(const FilePath &workingDir, args << extraOptions << file; VcsOutputWindow::setRepository(workingDir); VcsCommand *cmd = createCommand(workingDir, nullptr, VcsWindowOutputBind); - connect(cmd, &VcsCommand::done, VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository, - Qt::QueuedConnection); + connect(cmd, &VcsCommand::done, VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository); enqueueJob(cmd, args); } @@ -535,7 +534,7 @@ void VcsBaseClient::update(const FilePath &repositoryRoot, const QString &revisi connect(cmd, &VcsCommand::done, this, [this, repositoryRoot, cmd] { if (cmd->result() == ProcessResult::FinishedWithSuccess) emit changed(repositoryRoot.toString()); - }, Qt::QueuedConnection); + }); enqueueJob(cmd, args); }