From de4f71b2cfb159cbbfcc9c2529be7864b837e752 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 2 May 2022 23:14:40 +0200 Subject: [PATCH] MemcheckTool: Don't use SshConnection::connectionInfo() Use QtcProcess with a path on device instead. Invoke directly echo -n $SSH_CLIENT command and parse the output locally. That was the only usage of SshConnection::connectionInfo() in the whole Creator codebase. Change-Id: I23a548e8dcfdff370d5db4c7ef10a560d5adc57e Reviewed-by: hjk Reviewed-by: --- src/plugins/valgrind/memchecktool.cpp | 49 +++++++++++++-------------- src/plugins/valgrind/memchecktool.h | 2 +- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index d66892b0173..998268c9a0b 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -72,13 +72,11 @@ #include #include -#include -#include - #include #include #include #include +#include #include #include @@ -156,37 +154,38 @@ public: void start() override { - m_connection = QSsh::SshConnectionManager::acquireConnection(device()->sshParameters()); - if (!m_connection) { - reportFailure(); - return; - } - - connect(m_connection, &QSsh::SshConnection::errorOccurred, this, [this] { - reportFailure(); - }); - - auto connected = [this] { - *m_localServerAddress = m_connection->connectionInfo().localAddress; + QTC_ASSERT(!m_process, return); + m_process.reset(new QtcProcess); + m_process->setCommand({device()->mapToGlobalPath("echo"), "-n $SSH_CLIENT", CommandLine::Raw}); + connect(m_process.get(), &QtcProcess::done, this, [this] { + if (m_process->error() != QProcess::UnknownError) { + reportFailure(); + return; + } + const QByteArrayList data = m_process->readAllStandardOutput().split(' '); + if (data.size() != 3) { + reportFailure(); + return; + } + QHostAddress hostAddress; + if (!hostAddress.setAddress(QString::fromLatin1(data.first()))) { + reportFailure(); + return; + } + *m_localServerAddress = hostAddress; reportStarted(); - }; - if (m_connection->state() == QSsh::SshConnection::Connected) { - connected(); - } else { - connect(m_connection, &QSsh::SshConnection::connected, this, connected); - m_connection->connectToHost(); - } + m_process.release()->deleteLater(); + }); + m_process->start(); } void stop() override { - if (m_connection) - QSsh::SshConnectionManager::releaseConnection(m_connection); reportStopped(); } private: - QSsh::SshConnection *m_connection = nullptr; + std::unique_ptr m_process = nullptr; QHostAddress *m_localServerAddress = nullptr; }; diff --git a/src/plugins/valgrind/memchecktool.h b/src/plugins/valgrind/memchecktool.h index 99808a97c20..1e4e245cd78 100644 --- a/src/plugins/valgrind/memchecktool.h +++ b/src/plugins/valgrind/memchecktool.h @@ -26,7 +26,7 @@ #pragma once -#include +#include namespace Valgrind { namespace Internal {