diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index 8ef0cf52b03..5c15c2cc464 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -43,19 +43,13 @@ using namespace Utils; namespace VcsBase { -VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &environment) : - ShellCommand(workingDirectory, environment), - m_preventRepositoryChanged(false) +VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &environment) + : ShellCommand(workingDirectory, environment) { Environment env = environment; VcsBase::setProcessEnvironment(&env); setEnvironment(env); - connect(ICore::instance(), &ICore::coreAboutToClose, this, [this] { - m_preventRepositoryChanged = true; - abort(); - }); - VcsOutputWindow::setRepository(workingDirectory.toString()); setDisableUnixTerminal(); @@ -78,7 +72,13 @@ VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &envi connect(this, &ShellCommand::appendMessage, outputWindow, &VcsOutputWindow::appendMessage); connect(this, &ShellCommand::executedAsync, this, &VcsCommand::addTask); - connect(this, &ShellCommand::runCommandFinished, this, &VcsCommand::postRunCommand); + const auto connection = connect(this, &ShellCommand::runCommandFinished, + this, &VcsCommand::postRunCommand); + + connect(ICore::instance(), &ICore::coreAboutToClose, this, [this, connection] { + disconnect(connection); + abort(); + }); } void VcsCommand::addTask(const QFuture &future) @@ -110,7 +110,7 @@ void VcsCommand::addTask(const QFuture &future) void VcsCommand::postRunCommand(const FilePath &workingDirectory) { - if (m_preventRepositoryChanged || !(flags() & ShellCommand::ExpectRepoChanges)) + if (!(flags() & ShellCommand::ExpectRepoChanges)) return; // TODO tell the document manager that the directory now received all expected changes // Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory); diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h index 634981ff4af..9c0c6ba05e4 100644 --- a/src/plugins/vcsbase/vcscommand.h +++ b/src/plugins/vcsbase/vcscommand.h @@ -40,8 +40,6 @@ private: void addTask(const QFuture &future); void postRunCommand(const Utils::FilePath &workDirectory); - bool m_preventRepositoryChanged; - friend class VcsBaseClientImpl; };