aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <[email protected]>2025-07-02 16:03:55 +0200
committerJarek Kobus <[email protected]>2025-07-02 18:43:18 +0000
commit62eb12837a90271e5d9e860fcac6f7e644a58f0a (patch)
tree93164acb6dab502fa06cb9ca0881099b07d54fce
parenta9d509b831252c860d0183f741b346976e449cb1 (diff)
VcsCommand: Replace std[Out/Err]Text() signals with callbacksHEADmaster
Remove RunFlags::ProgressiveOutput flag. Change-Id: I114d2be21e33b56f4805b339c83c3d99081e1a84 Reviewed-by: Orgad Shaneh <[email protected]> Reviewed-by: AndrĂ© Hartmann <[email protected]>
-rw-r--r--src/plugins/gitlab/gitlabclonedialog.cpp11
-rw-r--r--src/plugins/vcsbase/vcscommand.cpp27
-rw-r--r--src/plugins/vcsbase/vcscommand.h5
-rw-r--r--src/plugins/vcsbase/vcsenums.h3
-rw-r--r--src/plugins/vcsbase/wizard/vcscommandpage.cpp11
5 files changed, 35 insertions, 22 deletions
diff --git a/src/plugins/gitlab/gitlabclonedialog.cpp b/src/plugins/gitlab/gitlabclonedialog.cpp
index 585b8ece48e..36f8db91682 100644
--- a/src/plugins/gitlab/gitlabclonedialog.cpp
+++ b/src/plugins/gitlab/gitlabclonedialog.cpp
@@ -139,12 +139,13 @@ void GitLabCloneDialog::cloneProject()
m_command = vc->createInitialCheckoutCommand({m_repositoryCB->currentText(),
m_pathChooser->absoluteFilePath(),
m_directoryLE->text(), extraArgs});
- m_command->addFlags(RunFlags::ProgressiveOutput);
- connect(m_command, &VcsCommand::stdOutText, this, [this](const QString &text) {
- m_cloneOutput->appendPlainText(text);
+ m_command->setStdOutCallback([cloneOutput = QPointer<QPlainTextEdit>(m_cloneOutput)](const QString &text) {
+ if (cloneOutput)
+ cloneOutput->appendPlainText(text);
});
- connect(m_command, &VcsCommand::stdErrText, this, [this](const QString &text) {
- m_cloneOutput->appendPlainText(text);
+ m_command->setStdErrCallback([cloneOutput = QPointer<QPlainTextEdit>(m_cloneOutput)](const QString &text) {
+ if (cloneOutput)
+ cloneOutput->appendPlainText(text);
});
connect(m_command, &VcsCommand::done, this, [this] {
cloneFinished(m_command->result() == ProcessResult::FinishedWithSuccess);
diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp
index a5d2a97acb4..1ccdeab006a 100644
--- a/src/plugins/vcsbase/vcscommand.cpp
+++ b/src/plugins/vcsbase/vcscommand.cpp
@@ -69,6 +69,8 @@ public:
Environment m_environment;
TextEncoding m_encoding;
ProgressParser m_progressParser = {};
+ TextChannelCallback m_stdOutCallback = {};
+ TextChannelCallback m_stdErrCallback = {};
QList<Job> m_jobs;
int m_currentJob = 0;
@@ -121,24 +123,23 @@ void VcsCommandPrivate::setupProcess(Process *process, const Job &job)
void VcsCommandPrivate::installStdCallbacks(Process *process)
{
- if (!(m_flags & RunFlags::MergeOutputChannels) && (m_flags & RunFlags::ProgressiveOutput
- || m_progressParser || !(m_flags & RunFlags::SuppressStdErr))) {
+ if (!(m_flags & RunFlags::MergeOutputChannels) && (m_stdErrCallback || m_progressParser
+ || !(m_flags & RunFlags::SuppressStdErr))) {
process->setTextChannelMode(Channel::Error, TextChannelMode::MultiLine);
connect(process, &Process::textOnStandardError, this, [this](const QString &text) {
if (!(m_flags & RunFlags::SuppressStdErr))
VcsOutputWindow::appendError(m_defaultWorkingDirectory, text);
- if (m_flags & RunFlags::ProgressiveOutput)
- emit q->stdErrText(text);
+ if (m_stdErrCallback)
+ m_stdErrCallback(text);
});
}
- if (m_progressParser || m_flags & RunFlags::ProgressiveOutput
- || m_flags & RunFlags::ShowStdOut) {
+ if (m_progressParser || m_stdOutCallback || m_flags & RunFlags::ShowStdOut) {
process->setTextChannelMode(Channel::Output, TextChannelMode::MultiLine);
connect(process, &Process::textOnStandardOutput, this, [this](const QString &text) {
if (m_flags & RunFlags::ShowStdOut)
VcsOutputWindow::appendSilently(m_defaultWorkingDirectory, text);
- if (m_flags & RunFlags::ProgressiveOutput)
- emit q->stdOutText(text);
+ if (m_stdOutCallback)
+ m_stdOutCallback(text);
});
}
}
@@ -323,6 +324,16 @@ void VcsCommand::setProgressParser(const ProgressParser &parser)
d->m_progressParser = parser;
}
+void VcsCommand::setStdOutCallback(const Utils::TextChannelCallback &callback)
+{
+ d->m_stdOutCallback = callback;
+}
+
+void VcsCommand::setStdErrCallback(const Utils::TextChannelCallback &callback)
+{
+ d->m_stdErrCallback = callback;
+}
+
CommandResult::CommandResult(const Process &process)
: m_result(process.result())
, m_exitCode(process.exitCode())
diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h
index c4e5fc8c28a..65772ef545c 100644
--- a/src/plugins/vcsbase/vcscommand.h
+++ b/src/plugins/vcsbase/vcscommand.h
@@ -79,6 +79,9 @@ public:
void setProgressParser(const Core::ProgressParser &parser);
+ void setStdOutCallback(const Utils::TextChannelCallback &callback);
+ void setStdErrCallback(const Utils::TextChannelCallback &callback);
+
static CommandResult runBlocking(const Utils::FilePath &workingDirectory,
const Utils::Environment &environment,
const Utils::CommandLine &command,
@@ -92,8 +95,6 @@ public:
Utils::ProcessResult result() const;
signals:
- void stdOutText(const QString &);
- void stdErrText(const QString &);
void done();
private:
diff --git a/src/plugins/vcsbase/vcsenums.h b/src/plugins/vcsbase/vcsenums.h
index 5a5b2c42a74..235a1ef0db5 100644
--- a/src/plugins/vcsbase/vcsenums.h
+++ b/src/plugins/vcsbase/vcsenums.h
@@ -20,8 +20,7 @@ enum class RunFlags {
SuppressCommandLogging = (1 << 5), // No starting command log entry.
ShowSuccessMessage = (1 << 6), // Show message about successful completion of command.
ShowStdOut = (1 << 7), // Show standard output.
- ProgressiveOutput = (1 << 8), // Emit stdOutText() and stdErrText() signals.
- ExpectRepoChanges = (1 << 9), // Expect changes in repository by the command.
+ ExpectRepoChanges = (1 << 8), // Expect changes in repository by the command.
NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging
};
diff --git a/src/plugins/vcsbase/wizard/vcscommandpage.cpp b/src/plugins/vcsbase/wizard/vcscommandpage.cpp
index ab38414464c..e56a5502110 100644
--- a/src/plugins/vcsbase/wizard/vcscommandpage.cpp
+++ b/src/plugins/vcsbase/wizard/vcscommandpage.cpp
@@ -352,12 +352,13 @@ void VcsCommandPage::start(VcsCommand *command)
QTC_ASSERT(m_state != Running, return);
m_command = command;
- m_command->addFlags(RunFlags::ProgressiveOutput);
- connect(m_command, &VcsCommand::stdOutText, this, [this](const QString &text) {
- m_formatter->appendMessage(text, StdOutFormat);
+ m_command->setStdOutCallback([formatter = QPointer<OutputFormatter>(m_formatter)](const QString &text) {
+ if (formatter)
+ formatter->appendMessage(text, StdOutFormat);
});
- connect(m_command, &VcsCommand::stdErrText, this, [this](const QString &text) {
- m_formatter->appendMessage(text, StdErrFormat);
+ m_command->setStdErrCallback([formatter = QPointer<OutputFormatter>(m_formatter)](const QString &text) {
+ if (formatter)
+ formatter->appendMessage(text, StdErrFormat);
});
connect(m_command, &VcsCommand::done, this, [this] {
finished(m_command->result() == ProcessResult::FinishedWithSuccess);