forked from qt-creator/qt-creator
SshRemoteProcess: Get rid of error arg from done() signal
Prepare for signal rename done() -> finished(). Change-Id: I81a7bd0a4826ce6200f4af47ba5868ceedb42206 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -58,14 +58,13 @@ SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &co
|
|||||||
m_connectionArgs = connectionArgs;
|
m_connectionArgs = connectionArgs;
|
||||||
|
|
||||||
connect(this, &QtcProcess::finished, this, [this] {
|
connect(this, &QtcProcess::finished, this, [this] {
|
||||||
QString error;
|
|
||||||
if (exitStatus() == QProcess::CrashExit)
|
if (exitStatus() == QProcess::CrashExit)
|
||||||
error = tr("The ssh process crashed: %1").arg(errorString());
|
setErrorString(tr("The ssh process crashed: %1").arg(errorString()));
|
||||||
emit done(error);
|
emit done();
|
||||||
});
|
});
|
||||||
connect(this, &QtcProcess::errorOccurred, [this](QProcess::ProcessError error) {
|
connect(this, &QtcProcess::errorOccurred, [this](QProcess::ProcessError error) {
|
||||||
if (error == QProcess::FailedToStart)
|
if (error == QProcess::FailedToStart)
|
||||||
emit done(errorString());
|
emit done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
static bool setupSshEnvironment(Utils::QtcProcess *process);
|
static bool setupSshEnvironment(Utils::QtcProcess *process);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void done(const QString &error);
|
void done();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_remoteCommand;
|
QString m_remoteCommand;
|
||||||
|
|||||||
@@ -142,11 +142,11 @@ void SshRemoteProcessRunner::handleProcessStarted()
|
|||||||
emit processStarted();
|
emit processStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshRemoteProcessRunner::handleProcessFinished(const QString &error)
|
void SshRemoteProcessRunner::handleProcessFinished()
|
||||||
{
|
{
|
||||||
d->m_exitStatus = d->m_process->exitStatus();
|
d->m_exitStatus = d->m_process->exitStatus();
|
||||||
d->m_exitCode = d->m_process->exitCode();
|
d->m_exitCode = d->m_process->exitCode();
|
||||||
d->m_processErrorString = error;
|
d->m_processErrorString = d->m_process->errorString();
|
||||||
setState(Inactive);
|
setState(Inactive);
|
||||||
emit processClosed(d->m_processErrorString);
|
emit processClosed(d->m_processErrorString);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ private:
|
|||||||
void handleConnectionError();
|
void handleConnectionError();
|
||||||
void handleDisconnected();
|
void handleDisconnected();
|
||||||
void handleProcessStarted();
|
void handleProcessStarted();
|
||||||
void handleProcessFinished(const QString &error);
|
void handleProcessFinished();
|
||||||
void runInternal(const QString &command, const QSsh::SshConnectionParameters &sshParams);
|
void runInternal(const QString &command, const QSsh::SshConnectionParameters &sshParams);
|
||||||
void setState(int newState);
|
void setState(int newState);
|
||||||
|
|
||||||
|
|||||||
@@ -196,8 +196,9 @@ void SshDeviceProcess::handleConnected()
|
|||||||
} else {
|
} else {
|
||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::started,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::started,
|
||||||
this, &SshDeviceProcess::handleProcessStarted);
|
this, &SshDeviceProcess::handleProcessStarted);
|
||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::done,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::done, this, [this] {
|
||||||
this, &SshDeviceProcess::handleProcessFinished);
|
handleProcessFinished(d->remoteProcess->errorString());
|
||||||
|
});
|
||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardOutput,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardOutput,
|
||||||
this, &QtcProcess::readyReadStandardOutput);
|
this, &QtcProcess::readyReadStandardOutput);
|
||||||
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardError,
|
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardError,
|
||||||
|
|||||||
@@ -200,12 +200,11 @@ void GenericDirectUploadService::runStat(const DeployableFile &file)
|
|||||||
const QString statCmd = "stat -t " + Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath());
|
const QString statCmd = "stat -t " + Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath());
|
||||||
SshRemoteProcess * const statProc = connection()->createRemoteProcess(statCmd).release();
|
SshRemoteProcess * const statProc = connection()->createRemoteProcess(statCmd).release();
|
||||||
statProc->setParent(this);
|
statProc->setParent(this);
|
||||||
connect(statProc, &SshRemoteProcess::done, this,
|
connect(statProc, &SshRemoteProcess::done, this, [this, statProc, state = d->state] {
|
||||||
[this, statProc, state = d->state](const QString &errorMsg) {
|
|
||||||
QTC_ASSERT(d->state == state, return);
|
QTC_ASSERT(d->state == state, return);
|
||||||
const DeployableFile file = d->getFileForProcess(statProc);
|
const DeployableFile file = d->getFileForProcess(statProc);
|
||||||
QTC_ASSERT(file.isValid(), return);
|
QTC_ASSERT(file.isValid(), return);
|
||||||
const QDateTime timestamp = timestampFromStat(file, statProc, errorMsg);
|
const QDateTime timestamp = timestampFromStat(file, statProc, statProc->errorString());
|
||||||
statProc->deleteLater();
|
statProc->deleteLater();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PreChecking:
|
case PreChecking:
|
||||||
@@ -342,11 +341,11 @@ void GenericDirectUploadService::chmod()
|
|||||||
SshRemoteProcess * const chmodProc
|
SshRemoteProcess * const chmodProc
|
||||||
= connection()->createRemoteProcess(command).release();
|
= connection()->createRemoteProcess(command).release();
|
||||||
chmodProc->setParent(this);
|
chmodProc->setParent(this);
|
||||||
connect(chmodProc, &SshRemoteProcess::done, this,
|
connect(chmodProc, &SshRemoteProcess::done, this, [this, chmodProc, state = d->state] {
|
||||||
[this, chmodProc, state = d->state](const QString &error) {
|
|
||||||
QTC_ASSERT(state == d->state, return);
|
QTC_ASSERT(state == d->state, return);
|
||||||
const DeployableFile file = d->getFileForProcess(chmodProc);
|
const DeployableFile file = d->getFileForProcess(chmodProc);
|
||||||
QTC_ASSERT(file.isValid(), return);
|
QTC_ASSERT(file.isValid(), return);
|
||||||
|
const QString error = chmodProc->errorString();
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
emit warningMessage(tr("Remote chmod failed for file \"%1\": %2")
|
emit warningMessage(tr("Remote chmod failed for file \"%1\": %2")
|
||||||
.arg(file.remoteFilePath(), error));
|
.arg(file.remoteFilePath(), error));
|
||||||
|
|||||||
@@ -143,11 +143,11 @@ void GenericLinuxDeviceTester::handleConnectionFailure()
|
|||||||
setFinished(TestFailure);
|
setFinished(TestFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericLinuxDeviceTester::handleProcessFinished(const QString &error)
|
void GenericLinuxDeviceTester::handleProcessFinished()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->state == RunningUname, return);
|
QTC_ASSERT(d->state == RunningUname, return);
|
||||||
|
|
||||||
if (!error.isEmpty() || d->process->exitCode() != 0) {
|
if (!d->process->errorString().isEmpty() || d->process->exitCode() != 0) {
|
||||||
const QByteArray stderrOutput = d->process->readAllStandardError();
|
const QByteArray stderrOutput = d->process->readAllStandardError();
|
||||||
if (!stderrOutput.isEmpty())
|
if (!stderrOutput.isEmpty())
|
||||||
emit errorMessage(tr("uname failed: %1").arg(QString::fromUtf8(stderrOutput)) + QLatin1Char('\n'));
|
emit errorMessage(tr("uname failed: %1").arg(QString::fromUtf8(stderrOutput)) + QLatin1Char('\n'));
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void handleConnected();
|
void handleConnected();
|
||||||
void handleConnectionFailure();
|
void handleConnectionFailure();
|
||||||
void handleProcessFinished(const QString &error);
|
void handleProcessFinished();
|
||||||
void handlePortsGatheringError(const QString &message);
|
void handlePortsGatheringError(const QString &message);
|
||||||
void handlePortListReady();
|
void handlePortListReady();
|
||||||
void handleSftpStarted();
|
void handleSftpStarted();
|
||||||
|
|||||||
@@ -103,8 +103,9 @@ void RsyncDeployService::createRemoteDirectories()
|
|||||||
remoteDirs.removeDuplicates();
|
remoteDirs.removeDuplicates();
|
||||||
m_mkdir = connection()->createRemoteProcess("mkdir -p " +
|
m_mkdir = connection()->createRemoteProcess("mkdir -p " +
|
||||||
ProcessArgs::createUnixArgs(remoteDirs).toString());
|
ProcessArgs::createUnixArgs(remoteDirs).toString());
|
||||||
connect(m_mkdir.get(), &SshRemoteProcess::done, this, [this](const QString &error) {
|
connect(m_mkdir.get(), &SshRemoteProcess::done, this, [this] {
|
||||||
QString userError;
|
QString userError;
|
||||||
|
const QString error = m_mkdir->errorString();
|
||||||
if (!error.isEmpty())
|
if (!error.isEmpty())
|
||||||
userError = error;
|
userError = error;
|
||||||
if (m_mkdir->exitCode() != 0)
|
if (m_mkdir->exitCode() != 0)
|
||||||
|
|||||||
@@ -95,10 +95,10 @@ void Shell::handleRemoteStderr()
|
|||||||
std::cerr << m_shell->readAllStandardError().data() << std::flush;
|
std::cerr << m_shell->readAllStandardError().data() << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shell::handleChannelClosed(const QString &error)
|
void Shell::handleChannelClosed()
|
||||||
{
|
{
|
||||||
std::cerr << "Shell closed. Exit code was " << m_shell->exitCode() << "." << std::endl;
|
std::cerr << "Shell closed. Exit code was " << m_shell->exitCode() << "." << std::endl;
|
||||||
QCoreApplication::exit(error.isEmpty() && m_shell->exitCode() == 0
|
QCoreApplication::exit(m_shell->errorString().isEmpty() && m_shell->exitCode() == 0
|
||||||
? EXIT_SUCCESS : EXIT_FAILURE);
|
? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ private:
|
|||||||
void handleRemoteStdout();
|
void handleRemoteStdout();
|
||||||
void handleRemoteStderr();
|
void handleRemoteStderr();
|
||||||
void handleShellMessage(const QString &message);
|
void handleShellMessage(const QString &message);
|
||||||
void handleChannelClosed(const QString &error);
|
void handleChannelClosed();
|
||||||
void handleShellStarted();
|
void handleShellStarted();
|
||||||
void handleStdin();
|
void handleStdin();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user