ShellCommand: Remove success() signal

Use finished() signal instead.

Change-Id: I4e28a2c6d90f40790cb9d19411186bd98402f4bb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-07-29 12:48:29 +02:00
parent 79aaf155b7
commit e6e4bc8dad
5 changed files with 41 additions and 26 deletions

View File

@@ -279,13 +279,11 @@ void ShellCommand::run(QFutureInterface<void> &future)
}
emit finished(lastExecSuccess, cookie());
if (lastExecSuccess) {
emit success(cookie());
if (lastExecSuccess)
future.setProgressValue(future.progressMaximum());
} else {
else
future.cancel(); // sets the progress indicator red
}
}
if (d->m_progressParser)
d->m_progressParser->setFuture(nullptr);

View File

@@ -144,7 +144,6 @@ signals:
void stdErrText(const QString &);
void started();
void finished(bool success, const QVariant &cookie);
void success(const QVariant &cookie);
void terminate(); // Internal

View File

@@ -984,25 +984,25 @@ void GitClient::chunkActionsRequested(DiffEditor::DiffEditorController *controll
menu->addSeparator();
QAction *stageChunkAction = menu->addAction(tr("Stage Chunk"));
connect(stageChunkAction, &QAction::triggered, this,
[stageChunk, diffController, fileIndex, chunkIndex]() {
[stageChunk, diffController, fileIndex, chunkIndex] {
stageChunk(diffController, fileIndex, chunkIndex,
DiffEditorController::NoOption, DiffEditor::ChunkSelection());
});
QAction *stageLinesAction = menu->addAction(tr("Stage Selection (%n Lines)", "", selection.selectedRowsCount()));
connect(stageLinesAction, &QAction::triggered, this,
[stageChunk, diffController, fileIndex, chunkIndex, selection]() {
[stageChunk, diffController, fileIndex, chunkIndex, selection] {
stageChunk(diffController, fileIndex, chunkIndex,
DiffEditorController::NoOption, selection);
});
QAction *unstageChunkAction = menu->addAction(tr("Unstage Chunk"));
connect(unstageChunkAction, &QAction::triggered, this,
[stageChunk, diffController, fileIndex, chunkIndex]() {
[stageChunk, diffController, fileIndex, chunkIndex] {
stageChunk(diffController, fileIndex, chunkIndex,
DiffEditorController::Revert, DiffEditor::ChunkSelection());
});
QAction *unstageLinesAction = menu->addAction(tr("Unstage Selection (%n Lines)", "", selection.selectedRowsCount()));
connect(unstageLinesAction, &QAction::triggered, this,
[stageChunk, diffController, fileIndex, chunkIndex, selection]() {
[stageChunk, diffController, fileIndex, chunkIndex, selection] {
stageChunk(diffController, fileIndex, chunkIndex,
DiffEditorController::Revert,
selection);
@@ -1199,7 +1199,7 @@ void GitClient::log(const FilePath &workingDirectory, const QString &fileName,
argWidget = new GitLogArgumentsWidget(settings(), !fileName.isEmpty(), editor);
argWidget->setBaseArguments(args);
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
[=]() { this->log(workingDir, fileName, enableAnnotationContextMenu, args); });
[=] { this->log(workingDir, fileName, enableAnnotationContextMenu, args); });
editor->setEditorConfig(argWidget);
}
editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
@@ -1506,8 +1506,10 @@ void GitClient::removeStaleRemoteBranches(const FilePath &workingDirectory, cons
ShellCommand *command = vcsExec(workingDirectory, arguments, nullptr, true,
ShellCommand::ShowSuccessMessage);
connect(command, &ShellCommand::success,
this, [workingDirectory]() { GitPlugin::updateBranches(workingDirectory); });
connect(command, &ShellCommand::finished, this, [workingDirectory](bool success) {
if (success)
GitPlugin::updateBranches(workingDirectory);
});
}
void GitClient::recoverDeletedFiles(const FilePath &workingDirectory)
@@ -3150,8 +3152,10 @@ void GitClient::fetch(const FilePath &workingDirectory, const QString &remote)
QStringList const arguments = {"fetch", (remote.isEmpty() ? "--all" : remote)};
ShellCommand *command = vcsExec(workingDirectory, arguments, nullptr, true,
ShellCommand::ShowSuccessMessage);
connect(command, &ShellCommand::success,
this, [workingDirectory] { GitPlugin::updateBranches(workingDirectory); });
connect(command, &ShellCommand::finished, this, [workingDirectory](bool success) {
if (success)
GitPlugin::updateBranches(workingDirectory);
});
}
bool GitClient::executeAndHandleConflicts(const FilePath &workingDirectory,
@@ -3182,9 +3186,10 @@ void GitClient::pull(const FilePath &workingDirectory, bool rebase)
}
ShellCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase, abortCommand);
connect(command, &ShellCommand::success, this,
[this, workingDirectory] { updateSubmodulesIfNeeded(workingDirectory, true); },
Qt::QueuedConnection);
connect(command, &ShellCommand::finished, this, [this, workingDirectory](bool success) {
if (success)
updateSubmodulesIfNeeded(workingDirectory, true);
}, Qt::QueuedConnection);
}
void GitClient::synchronousAbortCommand(const FilePath &workingDir, const QString &abortCommand)
@@ -3368,8 +3373,10 @@ void GitClient::push(const FilePath &workingDirectory, const QStringList &pushAr
ShellCommand *rePushCommand = vcsExec(workingDirectory,
QStringList({"push", "--force-with-lease"}) + pushArgs,
nullptr, true, ShellCommand::ShowSuccessMessage);
connect(rePushCommand, &ShellCommand::success,
this, []() { GitPlugin::updateCurrentBranch(); });
connect(rePushCommand, &ShellCommand::finished, this, [](bool success) {
if (success)
GitPlugin::updateCurrentBranch();
});
}
break;
}
@@ -3389,7 +3396,9 @@ void GitClient::push(const FilePath &workingDirectory, const QStringList &pushAr
ShellCommand *rePushCommand = vcsExec(workingDirectory,
fallbackCommandParts.mid(1), nullptr, true,
ShellCommand::ShowSuccessMessage);
connect(rePushCommand, &ShellCommand::success, this, [workingDirectory]() {
connect(rePushCommand, &ShellCommand::finished, this,
[workingDirectory](bool success) {
if (success)
GitPlugin::updateBranches(workingDirectory);
});
}

View File

@@ -570,7 +570,10 @@ void VcsBaseClient::revertFile(const FilePath &workingDir,
// Indicate repository change or file list
ShellCommand *cmd = createCommand(workingDir);
cmd->setCookie(QStringList(workingDir.pathAppended(file).toString()));
connect(cmd, &ShellCommand::success, this, &VcsBaseClient::changed, Qt::QueuedConnection);
connect(cmd, &ShellCommand::finished, this, [this](bool success, const QVariant &cookie) {
if (success)
emit changed(cookie);
}, Qt::QueuedConnection);
enqueueJob(cmd, args);
}
@@ -583,7 +586,10 @@ void VcsBaseClient::revertAll(const FilePath &workingDir,
// Indicate repository change or file list
ShellCommand *cmd = createCommand(workingDir);
cmd->setCookie(QStringList(workingDir.toString()));
connect(cmd, &ShellCommand::success, this, &VcsBaseClient::changed, Qt::QueuedConnection);
connect(cmd, &ShellCommand::finished, this, [this](bool success, const QVariant &cookie) {
if (success)
emit changed(cookie);
}, Qt::QueuedConnection);
enqueueJob(createCommand(workingDir), args);
}
@@ -681,7 +687,10 @@ void VcsBaseClient::update(const FilePath &repositoryRoot, const QString &revisi
args << revisionSpec(revision) << extraOptions;
ShellCommand *cmd = createCommand(repositoryRoot);
cmd->setCookie(repositoryRoot.toString());
connect(cmd, &ShellCommand::success, this, &VcsBaseClient::changed, Qt::QueuedConnection);
connect(cmd, &ShellCommand::finished, this, [this](bool success, const QVariant &cookie) {
if (success)
emit changed(cookie);
}, Qt::QueuedConnection);
enqueueJob(cmd, args);
}
@@ -702,7 +711,7 @@ void VcsBaseClient::commit(const FilePath &repositoryRoot,
args << extraOptions << files;
ShellCommand *cmd = createCommand(repositoryRoot, nullptr, VcsWindowOutputBind);
if (!commitMessageFile.isEmpty())
connect(cmd, &ShellCommand::finished, [commitMessageFile]() { QFile(commitMessageFile).remove(); });
connect(cmd, &ShellCommand::finished, [commitMessageFile] { QFile(commitMessageFile).remove(); });
enqueueJob(cmd, args);
}

View File

@@ -259,7 +259,7 @@ protected:
QString vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const;
private:
void statusParser(const QString&);
void statusParser(const QString &);
VcsBaseClient::ConfigCreator m_diffConfigCreator;
VcsBaseClient::ConfigCreator m_logConfigCreator;