Commit b54ab83b authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Command: Do not emit repositoryChanged when app is closed

Command is threaded, so it can be destructed after VcsManager is gone

Change-Id: I9618412aec502218f3c6b656ad2145b6a0aa28b5
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 017e1087
......@@ -103,6 +103,7 @@ public:
VcsBase::VcsBaseOutputWindow *m_outputWindow;
bool m_progressiveOutput;
bool m_hadOutput;
bool m_preventRepositoryChanged;
QFutureWatcher<void> m_watcher;
QList<Job> m_jobs;
......@@ -125,6 +126,7 @@ CommandPrivate::CommandPrivate(const QString &binary,
m_outputWindow(VcsBase::VcsBaseOutputWindow::instance()),
m_progressiveOutput(false),
m_hadOutput(false),
m_preventRepositoryChanged(false),
m_lastExecSuccess(false),
m_lastExecExitCode(-1)
{
......@@ -152,6 +154,8 @@ Command::Command(const QString &binary,
const QProcessEnvironment &environment) :
d(new Internal::CommandPrivate(binary, workingDirectory, environment))
{
connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()),
this, SLOT(coreAboutToClose()));
}
Command::~Command()
......@@ -423,11 +427,7 @@ Utils::SynchronousProcessResponse Command::runVcs(const QStringList &arguments,
} else if (!(d->m_flags & VcsBasePlugin::SuppressFailMessageInLogWindow)) {
emit outputProxy.appendError(response.exitMessage(d->m_binaryPath, timeoutMS));
}
if (d->m_flags & VcsBasePlugin::ExpectRepoChanges) {
// TODO tell the document manager that the directory now received all expected changes
// Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory);
Core::VcsManager::emitRepositoryChanged(d->m_workingDirectory);
}
emitRepositoryChanged();
return response;
}
......@@ -499,6 +499,15 @@ Utils::SynchronousProcessResponse Command::runSynchronous(const QStringList &arg
return response;
}
void Command::emitRepositoryChanged()
{
if (d->m_preventRepositoryChanged || !(d->m_flags & VcsBasePlugin::ExpectRepoChanges))
return;
// TODO tell the document manager that the directory now received all expected changes
// Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory);
Core::VcsManager::emitRepositoryChanged(d->m_workingDirectory);
}
bool Command::runFullySynchronous(const QStringList &arguments, int timeoutMS,
QByteArray *outputData, QByteArray *errorData)
{
......@@ -534,12 +543,7 @@ bool Command::runFullySynchronous(const QStringList &arguments, int timeoutMS,
return false;
}
if (d->m_flags & VcsBasePlugin::ExpectRepoChanges) {
// TODO tell the document manager that the directory now received all expected changes
// Core::DocumentManager::unexpectDirectoryChange(workingDirectory);
Core::VcsManager::emitRepositoryChanged(d->m_workingDirectory);
}
emitRepositoryChanged();
return process.exitStatus() == QProcess::NormalExit && process.exitCode() == 0;
}
......@@ -563,6 +567,12 @@ void Command::bufferedError(const QString &text)
emit errorText(text);
}
void Command::coreAboutToClose()
{
d->m_preventRepositoryChanged = true;
cancel();
}
const QVariant &Command::cookie() const
{
return d->m_cookie;
......
......@@ -112,6 +112,7 @@ private:
void run(QFutureInterface<void> &future);
Utils::SynchronousProcessResponse runSynchronous(const QStringList &arguments, int timeoutMS,
Utils::ExitCodeInterpreter *interpreter = 0);
void emitRepositoryChanged();
public slots:
void cancel();
......@@ -125,6 +126,7 @@ signals:
private slots:
void bufferedOutput(const QString &text);
void bufferedError(const QString &text);
void coreAboutToClose();
signals:
void terminate(); // Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment