VcsCommand: Get rid of abort()

Use destructor of VcsCommand instead.

Change-Id: Ie914d016c6d3d57a88674ce8534d5edec4bc79c1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-09-01 11:49:41 +02:00
parent 84426350d4
commit 2a2b136624
3 changed files with 28 additions and 40 deletions

View File

@@ -1387,7 +1387,7 @@ VcsBaseEditorConfig *VcsBaseEditorWidget::editorConfig() const
void VcsBaseEditorWidget::setCommand(VcsCommand *command) void VcsBaseEditorWidget::setCommand(VcsCommand *command)
{ {
if (d->m_command) { if (d->m_command) {
d->m_command->abort(); delete d->m_command;
hideProgressIndicator(); hideProgressIndicator();
} }
d->m_command = command; d->m_command = command;

View File

@@ -111,7 +111,6 @@ public:
unsigned m_flags = 0; unsigned m_flags = 0;
bool m_progressiveOutput = false; bool m_progressiveOutput = false;
bool m_aborted = false;
}; };
QString VcsCommandPrivate::displayName() const QString VcsCommandPrivate::displayName() const
@@ -216,7 +215,6 @@ bool VcsCommandPrivate::isFullySynchronous() const
void VcsCommandPrivate::handleDone(QtcProcess *process) void VcsCommandPrivate::handleDone(QtcProcess *process)
{ {
if (!m_aborted) {
// Success/Fail message in appropriate window? // Success/Fail message in appropriate window?
if (process->result() == ProcessResult::FinishedWithSuccess) { if (process->result() == ProcessResult::FinishedWithSuccess) {
if (m_flags & VcsCommand::ShowSuccessMessage) if (m_flags & VcsCommand::ShowSuccessMessage)
@@ -224,7 +222,6 @@ void VcsCommandPrivate::handleDone(QtcProcess *process)
} else if (!(m_flags & VcsCommand::SuppressFailMessage)) { } else if (!(m_flags & VcsCommand::SuppressFailMessage)) {
emit q->appendError(process->exitMessage()); emit q->appendError(process->exitMessage());
} }
}
emit q->runCommandFinished(process->workingDirectory()); emit q->runCommandFinished(process->workingDirectory());
} }
@@ -261,9 +258,6 @@ void VcsCommandPrivate::processDone()
startNextJob(); startNextJob();
return; return;
} }
if (m_aborted) {
m_futureInterface.reportCanceled();
} else {
if (!m_progressiveOutput) { if (!m_progressiveOutput) {
emit q->stdOutText(m_stdOut); emit q->stdOutText(m_stdOut);
if (!m_stdErr.isEmpty()) if (!m_stdErr.isEmpty())
@@ -272,7 +266,6 @@ void VcsCommandPrivate::processDone()
emit q->finished(success); emit q->finished(success);
if (!success) if (!success)
m_futureInterface.reportCanceled(); m_futureInterface.reportCanceled();
}
cleanup(); cleanup();
// As it is used asynchronously, we need to delete ourselves // As it is used asynchronously, we need to delete ourselves
q->deleteLater(); q->deleteLater();
@@ -298,7 +291,11 @@ VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &envi
this, &VcsCommand::postRunCommand); this, &VcsCommand::postRunCommand);
connect(ICore::instance(), &ICore::coreAboutToClose, this, [this, connection] { connect(ICore::instance(), &ICore::coreAboutToClose, this, [this, connection] {
disconnect(connection); disconnect(connection);
abort(); d->m_process.reset();
if (d->m_futureInterface.isRunning()) {
d->m_futureInterface.reportCanceled();
d->cleanup();
}
}); });
} }
@@ -357,12 +354,6 @@ void VcsCommand::execute()
ProgressManager::addTimedTask(d->m_futureInterface, name, id, qMax(2, d->timeoutS() / 5)); ProgressManager::addTimedTask(d->m_futureInterface, name, id, qMax(2, d->timeoutS() / 5));
} }
void VcsCommand::abort()
{
d->m_aborted = true;
d->m_watcher.future().cancel();
}
void VcsCommand::cancel() void VcsCommand::cancel()
{ {
d->m_futureInterface.reportCanceled(); d->m_futureInterface.reportCanceled();
@@ -404,7 +395,6 @@ void VcsCommand::runFullySynchronous(QtcProcess &process)
{ {
process.runBlocking(); process.runBlocking();
if (!d->m_aborted) {
const QString stdErr = process.cleanedStdErr(); const QString stdErr = process.cleanedStdErr();
if (!stdErr.isEmpty() && !(d->m_flags & SuppressStdErr)) if (!stdErr.isEmpty() && !(d->m_flags & SuppressStdErr))
emit append(stdErr); emit append(stdErr);
@@ -416,7 +406,6 @@ void VcsCommand::runFullySynchronous(QtcProcess &process)
else else
emit append(stdOut); emit append(stdOut);
} }
}
} }
void VcsCommand::runSynchronous(QtcProcess &process) void VcsCommand::runSynchronous(QtcProcess &process)

View File

@@ -105,7 +105,6 @@ public:
const Utils::FilePath &workingDirectory = {}, const Utils::FilePath &workingDirectory = {},
const Utils::ExitCodeInterpreter &interpreter = {}); const Utils::ExitCodeInterpreter &interpreter = {});
void execute(); // Execute tasks asynchronously! void execute(); // Execute tasks asynchronously!
void abort();
void addFlags(unsigned f); void addFlags(unsigned f);