forked from qt-creator/qt-creator
Fix a possible crash on shutdown while executing VcsCommand
Add a global synchronizer to the VcsPlugin. Fixes: QTCREATORBUG-25744 Change-Id: I97578f4a5b5275071aa0253a22fc9ab2f90d9b75 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "vcscommand.h"
|
||||
#include "vcsbaseplugin.h"
|
||||
#include "vcsoutputwindow.h"
|
||||
#include "vcsplugin.h"
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
@@ -78,6 +79,12 @@ void VcsCommand::runCommand(SynchronousProcess &proc,
|
||||
emitRepositoryChanged(workingDirectory);
|
||||
}
|
||||
|
||||
void VcsCommand::addTask(QFuture<void> &future)
|
||||
{
|
||||
Core::ShellCommand::addTask(future);
|
||||
Internal::VcsPlugin::addFuture(future);
|
||||
}
|
||||
|
||||
void VcsCommand::emitRepositoryChanged(const QString &workingDirectory)
|
||||
{
|
||||
if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges))
|
||||
|
@@ -51,6 +51,9 @@ public:
|
||||
const Utils::CommandLine &command,
|
||||
const QString &workDirectory = {}) override;
|
||||
|
||||
protected:
|
||||
void addTask(QFuture<void> &future) override;
|
||||
|
||||
private:
|
||||
void emitRepositoryChanged(const QString &workingDirectory);
|
||||
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
|
||||
#include <utils/futuresynchronizer.h>
|
||||
#include <utils/macroexpander.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -60,6 +61,7 @@ class VcsPluginPrivate
|
||||
public:
|
||||
CommonOptionsPage m_settingsPage;
|
||||
QStandardItemModel *m_nickNameModel = nullptr;
|
||||
Utils::FutureSynchronizer m_synchronizer;
|
||||
};
|
||||
|
||||
static VcsPlugin *m_instance = nullptr;
|
||||
@@ -71,6 +73,7 @@ VcsPlugin::VcsPlugin()
|
||||
|
||||
VcsPlugin::~VcsPlugin()
|
||||
{
|
||||
d->m_synchronizer.waitForFinished();
|
||||
VcsOutputWindow::destroy();
|
||||
m_instance = nullptr;
|
||||
delete d;
|
||||
@@ -82,6 +85,7 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
d = new VcsPluginPrivate;
|
||||
d->m_synchronizer.setCancelOnWait(true);
|
||||
|
||||
EditorManager::addCloseEditorListener([this](IEditor *editor) -> bool {
|
||||
bool result = true;
|
||||
@@ -140,6 +144,11 @@ VcsPlugin *VcsPlugin::instance()
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void VcsPlugin::addFuture(const QFuture<void> &future)
|
||||
{
|
||||
m_instance->d->m_synchronizer.addFuture(future);
|
||||
}
|
||||
|
||||
CommonVcsSettings &VcsPlugin::settings() const
|
||||
{
|
||||
return d->m_settingsPage.settings();
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <QFuture>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QStandardItemModel;
|
||||
QT_END_NAMESPACE
|
||||
@@ -51,6 +53,7 @@ public:
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
||||
|
||||
static VcsPlugin *instance();
|
||||
static void addFuture(const QFuture<void> &future);
|
||||
|
||||
CommonVcsSettings &settings() const;
|
||||
|
||||
|
Reference in New Issue
Block a user