Git: Fix crash on quit while rebase-todo editor is open

Change-Id: I458cbb2168642f226583b406e34596d223c7d5ea
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2013-07-31 21:12:41 +03:00
committed by Orgad Shaneh
parent 15a9019191
commit 3be6065b04
3 changed files with 36 additions and 25 deletions

View File

@@ -687,12 +687,16 @@ public:
~ConflictHandler() ~ConflictHandler()
{ {
GitClient *client = GitPlugin::instance()->gitClient(); // If interactive rebase editor window is closed, plugin is terminated
if (m_commit.isEmpty() && m_files.isEmpty()) { // but referenced here when the command ends
if (client->checkCommandInProgress(m_workingDirectory) == GitClient::NoCommand) if (GitPlugin *plugin = GitPlugin::instance()) {
client->endStashScope(m_workingDirectory); GitClient *client = plugin->gitClient();
} else { if (m_commit.isEmpty() && m_files.isEmpty()) {
client->handleMergeConflicts(m_workingDirectory, m_commit, m_files, m_command); if (client->checkCommandInProgress(m_workingDirectory) == GitClient::NoCommand)
client->endStashScope(m_workingDirectory);
} else {
client->handleMergeConflicts(m_workingDirectory, m_commit, m_files, m_command);
}
} }
} }

View File

@@ -33,6 +33,7 @@
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/vcsmanager.h> #include <coreplugin/vcsmanager.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <utils/runextensions.h>
#include <QDebug> #include <QDebug>
#include <QProcess> #include <QProcess>
@@ -202,7 +203,7 @@ void Command::execute()
return; return;
// For some reason QtConcurrent::run() only works on this // For some reason QtConcurrent::run() only works on this
QFuture<void> task = QtConcurrent::run(this, &Command::run); QFuture<void> task = QtConcurrent::run(&Command::run, this);
QString binary = QFileInfo(d->m_binaryPath).baseName(); QString binary = QFileInfo(d->m_binaryPath).baseName();
if (!binary.isEmpty()) if (!binary.isEmpty())
binary = binary.replace(0, 1, binary[0].toUpper()); // Upper the first letter binary = binary.replace(0, 1, binary[0].toUpper()); // Upper the first letter
@@ -226,7 +227,7 @@ QString Command::msgTimeout(int seconds)
return tr("Error: VCS timed out after %1s.").arg(seconds); return tr("Error: VCS timed out after %1s.").arg(seconds);
} }
void Command::run() void Command::run(QFutureInterface<void> &future)
{ {
// Check that the binary path is not empty // Check that the binary path is not empty
if (binaryPath().trimmed().isEmpty()) { if (binaryPath().trimmed().isEmpty()) {
@@ -284,23 +285,25 @@ void Command::run()
} }
} }
if (ok && d->m_jobs.front().arguments.at(0) == QLatin1String("status")) if (!future.isCanceled()) {
removeColorCodes(&stdOut); if (ok && d->m_jobs.front().arguments.at(0) == QLatin1String("status"))
removeColorCodes(&stdOut);
d->m_lastExecSuccess = ok; d->m_lastExecSuccess = ok;
d->m_lastExecExitCode = exitCode; d->m_lastExecExitCode = exitCode;
if (ok) if (ok)
emit outputData(stdOut); emit outputData(stdOut);
if (!error.isEmpty()) if (!error.isEmpty())
emit errorText(error); emit errorText(error);
emit finished(ok, exitCode, cookie()); emit finished(ok, exitCode, cookie());
if (ok) { if (ok) {
emit success(cookie()); emit success(cookie());
if (d->m_expectChanges) if (d->m_expectChanges)
Core::ICore::vcsManager()->emitRepositoryChanged(d->m_workingDirectory); Core::ICore::vcsManager()->emitRepositoryChanged(d->m_workingDirectory);
}
} }
// As it is used asynchronously, we need to delete ourselves // As it is used asynchronously, we need to delete ourselves

View File

@@ -34,9 +34,13 @@
#include <QObject> #include <QObject>
QT_FORWARD_DECLARE_CLASS(QStringList) QT_BEGIN_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QVariant) class QStringList;
QT_FORWARD_DECLARE_CLASS(QProcessEnvironment) class QVariant;
class QProcessEnvironment;
template <typename T>
class QFutureInterface;
QT_END_NAMESPACE
namespace VcsBase { namespace VcsBase {
@@ -94,7 +98,7 @@ public:
void setCookie(const QVariant &cookie); void setCookie(const QVariant &cookie);
private: private:
void run(); void run(QFutureInterface<void> &future);
signals: signals:
void outputData(const QByteArray &); void outputData(const QByteArray &);