forked from qt-creator/qt-creator
QtcSsh: Connect to QtcProcess::done() signal
Instead of connecting to errorOccurred() and finished() signals. Change-Id: I113f51564501a67725afee77ab4d20e5d954a7c0 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -118,25 +118,20 @@ SftpSession::SftpSession(const QStringList &connectionArgs) : d(new SftpSessionP
|
||||
qCDebug(sshLog) << "sftp process started";
|
||||
d->sftpProc.write("\n"); // Force initial prompt.
|
||||
});
|
||||
connect(&d->sftpProc, &QtcProcess::errorOccurred, [this](QProcess::ProcessError error) {
|
||||
if (error == QProcess::FailedToStart) {
|
||||
d->state = State::Inactive;
|
||||
emit done(tr("sftp failed to start: %1").arg(d->sftpProc.errorString()));
|
||||
}
|
||||
});
|
||||
connect(&d->sftpProc, &QtcProcess::finished, [this] {
|
||||
connect(&d->sftpProc, &QtcProcess::done, [this] {
|
||||
qCDebug(sshLog) << "sftp process finished";
|
||||
|
||||
d->state = State::Inactive;
|
||||
if (d->sftpProc.exitStatus() != QProcess::NormalExit) {
|
||||
emit done(tr("sftp crashed."));
|
||||
return;
|
||||
}
|
||||
if (d->sftpProc.exitCode() != 0) {
|
||||
emit done(QString::fromLocal8Bit(d->sftpProc.readAllStandardError()));
|
||||
return;
|
||||
}
|
||||
emit done(QString());
|
||||
const QString processMessage = [this] {
|
||||
if (d->sftpProc.error() == QProcess::FailedToStart)
|
||||
return tr("sftp failed to start: %1").arg(d->sftpProc.errorString());
|
||||
if (d->sftpProc.exitStatus() != QProcess::NormalExit)
|
||||
return tr("sftp crashed.");
|
||||
if (d->sftpProc.exitCode() != 0)
|
||||
return QString::fromLocal8Bit(d->sftpProc.readAllStandardError());
|
||||
return QString();
|
||||
}();
|
||||
emit done(processMessage);
|
||||
});
|
||||
connect(&d->sftpProc, &QtcProcess::readyReadStandardOutput, this, &SftpSession::handleStdout);
|
||||
}
|
||||
|
@@ -114,11 +114,11 @@ SftpTransfer::SftpTransfer(const FilesToTransfer &files, Internal::FileTransferT
|
||||
d->transferType = type;
|
||||
d->errorHandlingMode = errorHandlingMode;
|
||||
d->connectionArgs = connectionArgs;
|
||||
connect(&d->sftpProc, &QtcProcess::errorOccurred, [this](QProcess::ProcessError error) {
|
||||
if (error == QProcess::FailedToStart)
|
||||
connect(&d->sftpProc, &QtcProcess::done, [this] {
|
||||
if (d->sftpProc.error() == QProcess::FailedToStart) {
|
||||
emitError(tr("sftp failed to start: %1").arg(d->sftpProc.errorString()));
|
||||
});
|
||||
connect(&d->sftpProc, &QtcProcess::finished, [this] {
|
||||
return;
|
||||
}
|
||||
if (d->sftpProc.exitStatus() != QProcess::NormalExit) {
|
||||
emitError(tr("sftp crashed."));
|
||||
return;
|
||||
|
@@ -186,21 +186,12 @@ SshConnection::SshConnection(const SshConnectionParameters &serverInfo, QObject
|
||||
if (reply == "\n")
|
||||
emitConnected();
|
||||
});
|
||||
connect(&d->masterProcess, &QtcProcess::errorOccurred, [this] (QProcess::ProcessError error) {
|
||||
switch (error) {
|
||||
case QProcess::FailedToStart:
|
||||
connect(&d->masterProcess, &QtcProcess::done, this, [this] {
|
||||
if (d->masterProcess.error() == QProcess::FailedToStart) {
|
||||
emitError(tr("Cannot establish SSH connection: Control process failed to start: %1")
|
||||
.arg(d->fullProcessError()));
|
||||
break;
|
||||
case QProcess::Crashed: // Handled by finished() handler.
|
||||
case QProcess::Timedout:
|
||||
case QProcess::ReadError:
|
||||
case QProcess::WriteError:
|
||||
case QProcess::UnknownError:
|
||||
break; // Cannot happen.
|
||||
return;
|
||||
}
|
||||
});
|
||||
connect(&d->masterProcess, &QtcProcess::finished, [this] {
|
||||
if (d->state == Disconnecting) {
|
||||
emitDisconnected();
|
||||
return;
|
||||
|
Reference in New Issue
Block a user