forked from qt-creator/qt-creator
VcsBaseClientImpl: Don't leak VcsCommand instances
The running VcsCommand may leak on shutdown. Make them always a child of a guard object. Change-Id: Ie2d07d15cd13f1c08636bb1e9c5face09c6a782d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -953,7 +953,7 @@ VcsCommand *BazaarPluginPrivate::createInitialCheckoutCommand(const QString &url
|
||||
|
||||
Environment env = m_client.processEnvironment(baseDirectory);
|
||||
env.set("BZR_PROGRESS_BAR", "text");
|
||||
auto command = VcsBaseClient::createVcsCommand(baseDirectory, env);
|
||||
auto command = VcsBaseClient::createVcsCommand(this, baseDirectory, env);
|
||||
command->addJob({m_client.vcsBinary(baseDirectory), args}, -1);
|
||||
return command;
|
||||
}
|
||||
|
@@ -410,7 +410,8 @@ VcsCommand *CvsPluginPrivate::createInitialCheckoutCommand(const QString &url,
|
||||
QStringList args;
|
||||
args << QLatin1String("checkout") << url << extraArgs;
|
||||
|
||||
auto command = VcsBaseClient::createVcsCommand(baseDirectory, Environment::systemEnvironment());
|
||||
auto command = VcsBaseClient::createVcsCommand(this, baseDirectory,
|
||||
Environment::systemEnvironment());
|
||||
command->setDisplayName(Tr::tr("CVS Checkout"));
|
||||
command->addJob({settings().binaryPath(), settings().addOptions(args)}, -1);
|
||||
return command;
|
||||
|
@@ -927,7 +927,7 @@ VcsCommand *FossilPluginPrivate::createInitialCheckoutCommand(const QString &sou
|
||||
checkoutPath.createDir();
|
||||
|
||||
// Setup the wizard page command job
|
||||
auto command = VcsBaseClient::createVcsCommand(checkoutPath,
|
||||
auto command = VcsBaseClient::createVcsCommand(this, checkoutPath,
|
||||
fossilClient().processEnvironment(checkoutPath));
|
||||
|
||||
if (!isLocalRepository
|
||||
|
@@ -1769,7 +1769,7 @@ VcsCommand *GitPluginPrivate::createInitialCheckoutCommand(const QString &url,
|
||||
QStringList args = {"clone", "--progress"};
|
||||
args << extraArgs << url << localName;
|
||||
|
||||
auto command = VcsBaseClient::createVcsCommand(baseDirectory,
|
||||
auto command = VcsBaseClient::createVcsCommand(this, baseDirectory,
|
||||
gitClient().processEnvironment(baseDirectory));
|
||||
command->addFlags(RunFlags::SuppressStdErr);
|
||||
command->addJob({gitClient().vcsBinary(baseDirectory), args}, -1);
|
||||
|
@@ -736,9 +736,8 @@ VcsCommand *MercurialPluginPrivate::createInitialCheckoutCommand(const QString &
|
||||
{
|
||||
QStringList args;
|
||||
args << QLatin1String("clone") << extraArgs << url << localName;
|
||||
auto command = VcsBaseClient::createVcsCommand(baseDirectory,
|
||||
mercurialClient().processEnvironment(
|
||||
baseDirectory));
|
||||
auto command = VcsBaseClient::createVcsCommand(this, baseDirectory,
|
||||
mercurialClient().processEnvironment(baseDirectory));
|
||||
command->addJob({settings().binaryPath(), args}, -1);
|
||||
return command;
|
||||
}
|
||||
|
@@ -1135,9 +1135,8 @@ VcsCommand *SubversionPluginPrivate::createInitialCheckoutCommand(const QString
|
||||
args << SubversionClient::AddAuthOptions();
|
||||
args << Subversion::Constants::NON_INTERACTIVE_OPTION << extraArgs << url << localName;
|
||||
|
||||
auto command = VcsBaseClient::createVcsCommand(baseDirectory,
|
||||
subversionClient().processEnvironment(
|
||||
baseDirectory));
|
||||
auto command = VcsBaseClient::createVcsCommand(this, baseDirectory,
|
||||
subversionClient().processEnvironment(baseDirectory));
|
||||
command->addJob(args, -1);
|
||||
return command;
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "vcsbaseclientsettings.h"
|
||||
#include "vcsbaseeditor.h"
|
||||
#include "vcsbaseeditorconfig.h"
|
||||
#include "vcsbaseplugin.h"
|
||||
#include "vcsbasetr.h"
|
||||
#include "vcscommand.h"
|
||||
#include "vcsoutputwindow.h"
|
||||
@@ -72,7 +71,8 @@ FilePath VcsBaseClientImpl::vcsBinary(const Utils::FilePath &forDirectory) const
|
||||
VcsCommand *VcsBaseClientImpl::createCommand(const FilePath &workingDirectory,
|
||||
VcsBaseEditorWidget *editor) const
|
||||
{
|
||||
auto cmd = createVcsCommand(workingDirectory, processEnvironment(workingDirectory));
|
||||
auto cmd = createVcsCommand(const_cast<VcsBaseClientImpl *>(this),
|
||||
workingDirectory, processEnvironment(workingDirectory));
|
||||
if (editor) {
|
||||
editor->setCommand(cmd);
|
||||
connect(cmd, &VcsCommand::done, editor, [editor, cmd] {
|
||||
@@ -214,6 +214,14 @@ VcsCommand *VcsBaseClientImpl::createVcsCommand(const FilePath &defaultWorkingDi
|
||||
return new VcsCommand(defaultWorkingDir, environment);
|
||||
}
|
||||
|
||||
VcsCommand *VcsBaseClientImpl::createVcsCommand(QObject *parent, const FilePath &defaultWorkingDir,
|
||||
const Environment &environment)
|
||||
{
|
||||
auto command = new VcsCommand(defaultWorkingDir, environment);
|
||||
command->setParent(parent);
|
||||
return command;
|
||||
}
|
||||
|
||||
VcsBaseEditorWidget *VcsBaseClientImpl::createVcsEditor(Id kind, QString title,
|
||||
const FilePath &source, QTextCodec *codec,
|
||||
const char *registerDynamicProperty,
|
||||
|
@@ -44,8 +44,11 @@ public:
|
||||
virtual Utils::FilePath vcsBinary(const Utils::FilePath &forDirectory) const;
|
||||
int vcsTimeoutS() const;
|
||||
|
||||
// TODO: For master: remove this overload.
|
||||
static VcsCommand *createVcsCommand(const Utils::FilePath &defaultWorkingDir,
|
||||
const Utils::Environment &environment);
|
||||
static VcsCommand *createVcsCommand(QObject *parent, const Utils::FilePath &defaultWorkingDir,
|
||||
const Utils::Environment &environment);
|
||||
|
||||
VcsBaseEditorWidget *createVcsEditor(Utils::Id kind, QString title,
|
||||
const Utils::FilePath &source, QTextCodec *codec,
|
||||
|
@@ -65,6 +65,7 @@ class VCSBASE_EXPORT VcsCommand final : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// TODO: For master, make c'tor private and make it a friend to VcsBaseClientImpl.
|
||||
VcsCommand(const Utils::FilePath &workingDirectory, const Utils::Environment &environment);
|
||||
~VcsCommand() override;
|
||||
|
||||
|
Reference in New Issue
Block a user