forked from qt-creator/qt-creator
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 <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -72,13 +72,11 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
#include <ssh/sshconnection.h>
|
|
||||||
#include <ssh/sshconnectionmanager.h>
|
|
||||||
|
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -156,37 +154,38 @@ public:
|
|||||||
|
|
||||||
void start() override
|
void start() override
|
||||||
{
|
{
|
||||||
m_connection = QSsh::SshConnectionManager::acquireConnection(device()->sshParameters());
|
QTC_ASSERT(!m_process, return);
|
||||||
if (!m_connection) {
|
m_process.reset(new QtcProcess);
|
||||||
reportFailure();
|
m_process->setCommand({device()->mapToGlobalPath("echo"), "-n $SSH_CLIENT", CommandLine::Raw});
|
||||||
return;
|
connect(m_process.get(), &QtcProcess::done, this, [this] {
|
||||||
}
|
if (m_process->error() != QProcess::UnknownError) {
|
||||||
|
reportFailure();
|
||||||
connect(m_connection, &QSsh::SshConnection::errorOccurred, this, [this] {
|
return;
|
||||||
reportFailure();
|
}
|
||||||
});
|
const QByteArrayList data = m_process->readAllStandardOutput().split(' ');
|
||||||
|
if (data.size() != 3) {
|
||||||
auto connected = [this] {
|
reportFailure();
|
||||||
*m_localServerAddress = m_connection->connectionInfo().localAddress;
|
return;
|
||||||
|
}
|
||||||
|
QHostAddress hostAddress;
|
||||||
|
if (!hostAddress.setAddress(QString::fromLatin1(data.first()))) {
|
||||||
|
reportFailure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*m_localServerAddress = hostAddress;
|
||||||
reportStarted();
|
reportStarted();
|
||||||
};
|
m_process.release()->deleteLater();
|
||||||
if (m_connection->state() == QSsh::SshConnection::Connected) {
|
});
|
||||||
connected();
|
m_process->start();
|
||||||
} else {
|
|
||||||
connect(m_connection, &QSsh::SshConnection::connected, this, connected);
|
|
||||||
m_connection->connectToHost();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop() override
|
void stop() override
|
||||||
{
|
{
|
||||||
if (m_connection)
|
|
||||||
QSsh::SshConnectionManager::releaseConnection(m_connection);
|
|
||||||
reportStopped();
|
reportStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSsh::SshConnection *m_connection = nullptr;
|
std::unique_ptr<QtcProcess> m_process = nullptr;
|
||||||
QHostAddress *m_localServerAddress = nullptr;
|
QHostAddress *m_localServerAddress = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QObject>
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
Reference in New Issue
Block a user