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";
|
qCDebug(sshLog) << "sftp process started";
|
||||||
d->sftpProc.write("\n"); // Force initial prompt.
|
d->sftpProc.write("\n"); // Force initial prompt.
|
||||||
});
|
});
|
||||||
connect(&d->sftpProc, &QtcProcess::errorOccurred, [this](QProcess::ProcessError error) {
|
connect(&d->sftpProc, &QtcProcess::done, [this] {
|
||||||
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] {
|
|
||||||
qCDebug(sshLog) << "sftp process finished";
|
qCDebug(sshLog) << "sftp process finished";
|
||||||
|
|
||||||
d->state = State::Inactive;
|
d->state = State::Inactive;
|
||||||
if (d->sftpProc.exitStatus() != QProcess::NormalExit) {
|
const QString processMessage = [this] {
|
||||||
emit done(tr("sftp crashed."));
|
if (d->sftpProc.error() == QProcess::FailedToStart)
|
||||||
return;
|
return tr("sftp failed to start: %1").arg(d->sftpProc.errorString());
|
||||||
}
|
if (d->sftpProc.exitStatus() != QProcess::NormalExit)
|
||||||
if (d->sftpProc.exitCode() != 0) {
|
return tr("sftp crashed.");
|
||||||
emit done(QString::fromLocal8Bit(d->sftpProc.readAllStandardError()));
|
if (d->sftpProc.exitCode() != 0)
|
||||||
return;
|
return QString::fromLocal8Bit(d->sftpProc.readAllStandardError());
|
||||||
}
|
return QString();
|
||||||
emit done(QString());
|
}();
|
||||||
|
emit done(processMessage);
|
||||||
});
|
});
|
||||||
connect(&d->sftpProc, &QtcProcess::readyReadStandardOutput, this, &SftpSession::handleStdout);
|
connect(&d->sftpProc, &QtcProcess::readyReadStandardOutput, this, &SftpSession::handleStdout);
|
||||||
}
|
}
|
||||||
|
@@ -114,11 +114,11 @@ SftpTransfer::SftpTransfer(const FilesToTransfer &files, Internal::FileTransferT
|
|||||||
d->transferType = type;
|
d->transferType = type;
|
||||||
d->errorHandlingMode = errorHandlingMode;
|
d->errorHandlingMode = errorHandlingMode;
|
||||||
d->connectionArgs = connectionArgs;
|
d->connectionArgs = connectionArgs;
|
||||||
connect(&d->sftpProc, &QtcProcess::errorOccurred, [this](QProcess::ProcessError error) {
|
connect(&d->sftpProc, &QtcProcess::done, [this] {
|
||||||
if (error == QProcess::FailedToStart)
|
if (d->sftpProc.error() == QProcess::FailedToStart) {
|
||||||
emitError(tr("sftp failed to start: %1").arg(d->sftpProc.errorString()));
|
emitError(tr("sftp failed to start: %1").arg(d->sftpProc.errorString()));
|
||||||
});
|
return;
|
||||||
connect(&d->sftpProc, &QtcProcess::finished, [this] {
|
}
|
||||||
if (d->sftpProc.exitStatus() != QProcess::NormalExit) {
|
if (d->sftpProc.exitStatus() != QProcess::NormalExit) {
|
||||||
emitError(tr("sftp crashed."));
|
emitError(tr("sftp crashed."));
|
||||||
return;
|
return;
|
||||||
|
@@ -186,21 +186,12 @@ SshConnection::SshConnection(const SshConnectionParameters &serverInfo, QObject
|
|||||||
if (reply == "\n")
|
if (reply == "\n")
|
||||||
emitConnected();
|
emitConnected();
|
||||||
});
|
});
|
||||||
connect(&d->masterProcess, &QtcProcess::errorOccurred, [this] (QProcess::ProcessError error) {
|
connect(&d->masterProcess, &QtcProcess::done, this, [this] {
|
||||||
switch (error) {
|
if (d->masterProcess.error() == QProcess::FailedToStart) {
|
||||||
case QProcess::FailedToStart:
|
|
||||||
emitError(tr("Cannot establish SSH connection: Control process failed to start: %1")
|
emitError(tr("Cannot establish SSH connection: Control process failed to start: %1")
|
||||||
.arg(d->fullProcessError()));
|
.arg(d->fullProcessError()));
|
||||||
break;
|
return;
|
||||||
case QProcess::Crashed: // Handled by finished() handler.
|
|
||||||
case QProcess::Timedout:
|
|
||||||
case QProcess::ReadError:
|
|
||||||
case QProcess::WriteError:
|
|
||||||
case QProcess::UnknownError:
|
|
||||||
break; // Cannot happen.
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
connect(&d->masterProcess, &QtcProcess::finished, [this] {
|
|
||||||
if (d->state == Disconnecting) {
|
if (d->state == Disconnecting) {
|
||||||
emitDisconnected();
|
emitDisconnected();
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user