SSH: SshRemoteProcessRunner does not need to be a shared pointer.

Change-Id: I49cf2e113d23ebebe0939adbf90a1a88c84998a5
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Christian Kandeler
2011-10-28 16:10:26 +02:00
parent c8fc9b33ae
commit 2faf3b2548
18 changed files with 145 additions and 140 deletions

View File

@@ -234,24 +234,16 @@ void SshRemoteProcessRunnerPrivate::assertState(State allowedState,
} // namespace Internal
SshRemoteProcessRunner::Ptr SshRemoteProcessRunner::create(const SshConnectionParameters &params)
{
return SshRemoteProcessRunner::Ptr(new SshRemoteProcessRunner(params));
}
SshRemoteProcessRunner::Ptr SshRemoteProcessRunner::create(const SshConnection::Ptr &connection)
{
return SshRemoteProcessRunner::Ptr(new SshRemoteProcessRunner(connection));
}
SshRemoteProcessRunner::SshRemoteProcessRunner(const SshConnectionParameters &params)
: d(new Internal::SshRemoteProcessRunnerPrivate(params, this))
SshRemoteProcessRunner::SshRemoteProcessRunner(const SshConnectionParameters &params,
QObject *parent)
: QObject(parent), d(new Internal::SshRemoteProcessRunnerPrivate(params, this))
{
init();
}
SshRemoteProcessRunner::SshRemoteProcessRunner(const SshConnection::Ptr &connection)
: d(new Internal::SshRemoteProcessRunnerPrivate(connection, this))
SshRemoteProcessRunner::SshRemoteProcessRunner(const SshConnection::Ptr &connection,
QObject *parent)
: QObject(parent), d(new Internal::SshRemoteProcessRunnerPrivate(connection, this))
{
init();
}

View File

@@ -46,10 +46,8 @@ class QTCREATOR_UTILS_EXPORT SshRemoteProcessRunner : public QObject
Q_OBJECT
public:
typedef QSharedPointer<SshRemoteProcessRunner> Ptr;
static Ptr create(const SshConnectionParameters &params);
static Ptr create(const SshConnection::Ptr &connection);
SshRemoteProcessRunner(const SshConnectionParameters &params, QObject *parent = 0);
SshRemoteProcessRunner(const SshConnection::Ptr &connection, QObject *parent = 0);
void run(const QByteArray &command);
void runInTerminal(const QByteArray &command,
@@ -67,8 +65,6 @@ signals:
void processClosed(int exitStatus); // values are of type SshRemoteProcess::ExitStatus
private:
SshRemoteProcessRunner(const SshConnectionParameters &params);
SshRemoteProcessRunner(const SshConnection::Ptr &connection);
void init();
Internal::SshRemoteProcessRunnerPrivate *d;

View File

@@ -64,18 +64,23 @@
namespace Debugger {
namespace Internal {
SshIODevice::SshIODevice(Utils::SshRemoteProcessRunner::Ptr r)
SshIODevice::SshIODevice(Utils::SshRemoteProcessRunner *r)
: runner(r)
, buckethead(0)
{
setOpenMode(QIODevice::ReadWrite | QIODevice::Unbuffered);
connect (runner.data(), SIGNAL(processStarted()),
this, SLOT(processStarted()));
connect(runner.data(), SIGNAL(processOutputAvailable(const QByteArray &)),
connect (runner, SIGNAL(processStarted()), this, SLOT(processStarted()));
connect(runner, SIGNAL(processOutputAvailable(const QByteArray &)),
this, SLOT(outputAvailable(const QByteArray &)));
connect(runner.data(), SIGNAL(processErrorOutputAvailable(const QByteArray &)),
connect(runner, SIGNAL(processErrorOutputAvailable(const QByteArray &)),
this, SLOT(errorOutputAvailable(const QByteArray &)));
}
SshIODevice::~SshIODevice()
{
delete runner;
}
qint64 SshIODevice::bytesAvailable () const
{
qint64 r = QIODevice::bytesAvailable();
@@ -139,16 +144,16 @@ void SshIODevice::errorOutputAvailable(const QByteArray &output)
LldbEngineHost::LldbEngineHost(const DebuggerStartParameters &startParameters)
:IPCEngineHost(startParameters)
:IPCEngineHost(startParameters), m_ssh(0)
{
showMessage(QLatin1String("setting up coms"));
if (startParameters.startMode == StartRemoteEngine)
{
m_guestProcess = 0;
Utils::SshRemoteProcessRunner::Ptr runner =
Utils::SshRemoteProcessRunner::create(startParameters.connParams);
connect (runner.data(), SIGNAL(connectionError(Utils::SshError)),
Utils::SshRemoteProcessRunner * const runner =
new Utils::SshRemoteProcessRunner(startParameters.connParams);
connect (runner, SIGNAL(connectionError(Utils::SshError)),
this, SLOT(sshConnectionError(Utils::SshError)));
runner->run(startParameters.serverStartScript.toUtf8());
setGuestDevice(new SshIODevice(runner));
@@ -193,7 +198,7 @@ LldbEngineHost::~LldbEngineHost()
m_guestProcess->terminate();
m_guestProcess->kill();
}
if (m_ssh.data() && m_ssh->process().data()) {
if (m_ssh && m_ssh->process().data()) {
// TODO: openssh doesn't do that
m_ssh->process()->kill();

View File

@@ -49,7 +49,8 @@ class SshIODevice : public QIODevice
{
Q_OBJECT
public:
SshIODevice(Utils::SshRemoteProcessRunner::Ptr r);
SshIODevice(Utils::SshRemoteProcessRunner *r);
~SshIODevice();
virtual qint64 bytesAvailable () const;
virtual qint64 writeData (const char * data, qint64 maxSize);
virtual qint64 readData (char * data, qint64 maxSize);
@@ -58,7 +59,7 @@ private slots:
void outputAvailable(const QByteArray &output);
void errorOutputAvailable(const QByteArray &output);
private:
Utils::SshRemoteProcessRunner::Ptr runner;
Utils::SshRemoteProcessRunner *runner;
Utils::SshRemoteProcess::Ptr proc;
int buckethead;
QQueue<QByteArray> buckets;
@@ -75,7 +76,7 @@ public:
private:
QProcess *m_guestProcess;
Utils::SshRemoteProcessRunner::Ptr m_ssh;
Utils::SshRemoteProcessRunner *m_ssh;
protected:
void nuke();
private slots:

View File

@@ -52,7 +52,8 @@ const char QmlToolingDirectory[] = "/usr/lib/qt4/plugins/qmltooling";
MaddeDeviceTester::MaddeDeviceTester(QObject *parent)
: AbstractLinuxDeviceTester(parent),
m_genericTester(new GenericLinuxDeviceTester(this)),
m_state(Inactive)
m_state(Inactive),
m_processRunner(0)
{
}
@@ -106,14 +107,15 @@ void MaddeDeviceTester::handleGenericTestFinished(TestResult result)
return;
}
m_processRunner = SshRemoteProcessRunner::create(m_genericTester->connection());
connect(m_processRunner.data(), SIGNAL(connectionError(Utils::SshError)),
delete m_processRunner;
m_processRunner = new SshRemoteProcessRunner(m_genericTester->connection(), this);
connect(m_processRunner, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(m_processRunner.data(), SIGNAL(processOutputAvailable(QByteArray)),
connect(m_processRunner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleStdout(QByteArray)));
connect(m_processRunner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)),
connect(m_processRunner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleStderr(QByteArray)));
connect(m_processRunner.data(), SIGNAL(processClosed(int)), SLOT(handleProcessFinished(int)));
connect(m_processRunner, SIGNAL(processClosed(int)), SLOT(handleProcessFinished(int)));
QString qtInfoCmd;
if (m_deviceConfiguration->osType() == QLatin1String(MeeGoOsType)) {
@@ -282,8 +284,9 @@ QString MaddeDeviceTester::processedQtLibsList()
m_state = Inactive;
disconnect(m_genericTester, 0, this, 0);
if (m_processRunner)
disconnect(m_processRunner.data(), 0, this, 0);
m_processRunner.clear();
disconnect(m_processRunner, 0, this, 0);
delete m_processRunner;
m_processRunner = 0;
emit finished(m_result);
}

View File

@@ -73,7 +73,7 @@ private:
RemoteLinux::GenericLinuxDeviceTester * const m_genericTester;
State m_state;
TestResult m_result;
QSharedPointer<Utils::SshRemoteProcessRunner> m_processRunner;
Utils::SshRemoteProcessRunner *m_processRunner;
QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> m_deviceConfiguration;
QByteArray m_stdout;
QByteArray m_stderr;

View File

@@ -47,6 +47,7 @@
#include <remotelinux/deploymentinfo.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <utils/ssh/sshremoteprocessrunner.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
@@ -67,7 +68,8 @@ MaemoPublisherFremantleFree::MaemoPublisherFremantleFree(const ProjectExplorer::
QObject(parent),
m_project(project),
m_state(Inactive),
m_sshParams(SshConnectionParameters::DefaultProxy)
m_sshParams(SshConnectionParameters::DefaultProxy),
m_uploader(0)
{
m_sshParams.authenticationType = SshConnectionParameters::AuthenticationByKey;
m_sshParams.timeout = 30;
@@ -383,14 +385,13 @@ void MaemoPublisherFremantleFree::runDpkgBuildPackage()
// webmaster refuses to enable SFTP "for security reasons" ...
void MaemoPublisherFremantleFree::uploadPackage()
{
m_uploader = SshRemoteProcessRunner::create(m_sshParams);
connect(m_uploader.data(), SIGNAL(processStarted()),
SLOT(handleScpStarted()));
connect(m_uploader.data(), SIGNAL(connectionError(Utils::SshError)),
delete m_uploader;
m_uploader = new SshRemoteProcessRunner(m_sshParams, this);
connect(m_uploader, SIGNAL(processStarted()), SLOT(handleScpStarted()));
connect(m_uploader, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(m_uploader.data(), SIGNAL(processClosed(int)),
SLOT(handleUploadJobFinished(int)));
connect(m_uploader.data(), SIGNAL(processOutputAvailable(QByteArray)),
connect(m_uploader, SIGNAL(processClosed(int)), SLOT(handleUploadJobFinished(int)));
connect(m_uploader, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleScpStdOut(QByteArray)));
emit progressReport(tr("Starting scp ..."));
setState(StartingScp);
@@ -631,8 +632,9 @@ void MaemoPublisherFremantleFree::setState(State newState)
// TODO: Can we ensure the remote scp exits, e.g. by sending
// an illegal sequence of bytes? (Probably not, if
// we are currently uploading a file.)
disconnect(m_uploader.data(), 0, this, 0);
m_uploader = SshRemoteProcessRunner::Ptr();
disconnect(m_uploader, 0, this, 0);
delete m_uploader;
m_uploader = 0;
break;
default:
break;

View File

@@ -32,7 +32,7 @@
#ifndef MAEMOPUBLISHERFREMANTLEFREE_H
#define MAEMOPUBLISHERFREMANTLEFREE_H
#include <utils/ssh/sshremoteprocessrunner.h>
#include <utils/ssh/sshconnection.h>
#include <QtCore/QObject>
#include <QtCore/QProcess>
@@ -45,6 +45,10 @@ namespace Qt4ProjectManager {
class Qt4BuildConfiguration;
}
namespace Utils {
class SshRemoteProcessRunner;
}
namespace Madde {
namespace Internal {
@@ -116,7 +120,7 @@ private:
QProcess *m_process;
Utils::SshConnectionParameters m_sshParams;
QString m_remoteDir;
QSharedPointer<Utils::SshRemoteProcessRunner> m_uploader;
Utils::SshRemoteProcessRunner *m_uploader;
QByteArray m_scpOutput;
QList<QString> m_filesToUpload;
QString m_resultString;

View File

@@ -46,7 +46,7 @@ namespace Madde {
namespace Internal {
MaemoRemoteCopyFacility::MaemoRemoteCopyFacility(QObject *parent) :
QObject(parent), m_isCopying(false)
QObject(parent), m_isCopying(false), m_copyRunner(0)
{
}
@@ -63,16 +63,14 @@ void MaemoRemoteCopyFacility::copyFiles(const SshConnection::Ptr &connection,
m_deployables = deployables;
m_mountPoint = mountPoint;
m_copyRunner = SshRemoteProcessRunner::create(connection);
connect(m_copyRunner.data(), SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(m_copyRunner.data(), SIGNAL(processOutputAvailable(QByteArray)),
delete m_copyRunner;
m_copyRunner = new SshRemoteProcessRunner(connection, this);
connect(m_copyRunner, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError()));
connect(m_copyRunner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleRemoteStdout(QByteArray)));
connect(m_copyRunner.data(),
SIGNAL(processErrorOutputAvailable(QByteArray)),
connect(m_copyRunner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleRemoteStderr(QByteArray)));
connect(m_copyRunner.data(), SIGNAL(processClosed(int)),
SLOT(handleCopyFinished(int)));
connect(m_copyRunner, SIGNAL(processClosed(int)), SLOT(handleCopyFinished(int)));
m_isCopying = true;
copyNextFile();
@@ -82,8 +80,9 @@ void MaemoRemoteCopyFacility::cancel()
{
Q_ASSERT(m_isCopying);
SshRemoteProcessRunner::Ptr killProcess
= SshRemoteProcessRunner::create(m_copyRunner->connection());
// TODO: Make member as to not waste memory.
SshRemoteProcessRunner * const killProcess
= new SshRemoteProcessRunner(m_copyRunner->connection(), this);
killProcess->run("pkill cp");
setFinished();
}
@@ -151,8 +150,9 @@ void MaemoRemoteCopyFacility::copyNextFile()
void MaemoRemoteCopyFacility::setFinished()
{
disconnect(m_copyRunner.data(), 0, this, 0);
m_copyRunner.clear();
disconnect(m_copyRunner, 0, this, 0);
delete m_copyRunner;
m_copyRunner = 0;
m_deployables.clear();
m_isCopying = false;
}

View File

@@ -81,11 +81,11 @@ private:
void copyNextFile();
void setFinished();
QSharedPointer<Utils::SshRemoteProcessRunner> m_copyRunner;
Utils::SshRemoteProcessRunner *m_copyRunner;
QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> m_devConf;
QList<RemoteLinux::DeployableFile> m_deployables;
QString m_mountPoint;
bool m_isCopying;
bool m_isCopying; // TODO: Redundant due to being in sync with m_copyRunner?
};
} // namespace Internal

View File

@@ -47,11 +47,11 @@ enum State { Inactive, Running };
class RemoteLinuxCustomCommandDeployservicePrivate
{
public:
RemoteLinuxCustomCommandDeployservicePrivate() : state(Inactive) { }
RemoteLinuxCustomCommandDeployservicePrivate() : state(Inactive), runner(0) { }
QString commandLine;
State state;
SshRemoteProcessRunner::Ptr runner;
SshRemoteProcessRunner *runner;
};
} // namespace Internal
@@ -95,12 +95,13 @@ void RemoteLinuxCustomCommandDeployService::doDeploy()
{
QTC_ASSERT(d->state == Inactive, handleDeploymentDone());
d->runner = SshRemoteProcessRunner::create(connection());
connect(d->runner.data(), SIGNAL(processOutputAvailable(QByteArray)),
delete d->runner;
d->runner = new SshRemoteProcessRunner(connection(), this);
connect(d->runner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleStdout(QByteArray)));
connect(d->runner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)),
connect(d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleStderr(QByteArray)));
connect(d->runner.data(), SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
connect(d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
emit progressMessage(tr("Starting remote command '%1'...").arg(d->commandLine));
d->state = Running;
@@ -111,9 +112,10 @@ void RemoteLinuxCustomCommandDeployService::stopDeployment()
{
QTC_ASSERT(d->state == Running, return);
disconnect(d->runner.data(), 0, this, 0);
disconnect(d->runner, 0, this, 0);
d->runner->process()->closeChannel();
d->runner = SshRemoteProcessRunner::Ptr();
delete d->runner;
d->runner = 0;
d->state = Inactive;
handleDeploymentDone();
}

View File

@@ -44,6 +44,7 @@ RemoteLinuxEnvironmentReader::RemoteLinuxEnvironmentReader(RemoteLinuxRunConfigu
, m_stop(false)
, m_devConfig(config->deviceConfig())
, m_runConfig(config)
, m_remoteProcessRunner(0)
{
connect(config, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
this, SLOT(handleCurrentDeviceConfigChanged()));
@@ -61,19 +62,16 @@ void RemoteLinuxEnvironmentReader::start(const QString &environmentSetupCommand)
if (!m_remoteProcessRunner
|| m_remoteProcessRunner->connection()->state() != Utils::SshConnection::Connected
|| m_remoteProcessRunner->connection()->connectionParameters() != m_devConfig->sshParameters()) {
delete m_remoteProcessRunner;
m_remoteProcessRunner
= Utils::SshRemoteProcessRunner::create(m_devConfig->sshParameters());
= new Utils::SshRemoteProcessRunner(m_devConfig->sshParameters(), this);
}
connect(m_remoteProcessRunner.data(),
SIGNAL(connectionError(Utils::SshError)), this,
connect(m_remoteProcessRunner, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionFailure()));
connect(m_remoteProcessRunner.data(), SIGNAL(processClosed(int)), this,
SLOT(remoteProcessFinished(int)));
connect(m_remoteProcessRunner.data(),
SIGNAL(processOutputAvailable(QByteArray)), this,
connect(m_remoteProcessRunner, SIGNAL(processClosed(int)), SLOT(remoteProcessFinished(int)));
connect(m_remoteProcessRunner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(remoteOutput(QByteArray)));
connect(m_remoteProcessRunner.data(),
SIGNAL(processErrorOutputAvailable(QByteArray)), this,
connect(m_remoteProcessRunner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(remoteErrorOutput(QByteArray)));
const QByteArray remoteCall
= QString(environmentSetupCommand + QLatin1String("; env")).toUtf8();
@@ -85,7 +83,7 @@ void RemoteLinuxEnvironmentReader::stop()
{
m_stop = true;
if (m_remoteProcessRunner)
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
disconnect(m_remoteProcessRunner, 0, this, 0);
}
void RemoteLinuxEnvironmentReader::handleConnectionFailure()
@@ -93,7 +91,7 @@ void RemoteLinuxEnvironmentReader::handleConnectionFailure()
if (m_stop)
return;
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
disconnect(m_remoteProcessRunner, 0, this, 0);
emit error(tr("Connection error: %1")
.arg(m_remoteProcessRunner->connection()->errorString()));
emit finished();
@@ -104,7 +102,7 @@ void RemoteLinuxEnvironmentReader::handleCurrentDeviceConfigChanged()
m_devConfig = m_runConfig->deviceConfig();
if (m_remoteProcessRunner)
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
disconnect(m_remoteProcessRunner, 0, this, 0);
m_env.clear();
setFinished();
}
@@ -118,7 +116,7 @@ void RemoteLinuxEnvironmentReader::remoteProcessFinished(int exitCode)
if (m_stop)
return;
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
disconnect(m_remoteProcessRunner, 0, this, 0);
m_env.clear();
if (exitCode == Utils::SshRemoteProcess::ExitedNormally) {
if (!m_remoteOutput.isEmpty()) {

View File

@@ -80,7 +80,7 @@ private:
Utils::Environment m_env;
QSharedPointer<const LinuxDeviceConfiguration> m_devConfig;
RemoteLinuxRunConfiguration *m_runConfig;
QSharedPointer<Utils::SshRemoteProcessRunner> m_remoteProcessRunner;
Utils::SshRemoteProcessRunner *m_remoteProcessRunner;
};
} // namespace Internal

View File

@@ -45,10 +45,11 @@ namespace Internal {
class AbstractRemoteLinuxPackageInstallerPrivate
{
public:
AbstractRemoteLinuxPackageInstallerPrivate() : isRunning(false) {}
AbstractRemoteLinuxPackageInstallerPrivate() : isRunning(false), installer(0), killProcess(0) {}
bool isRunning;
Utils::SshRemoteProcessRunner::Ptr installer;
Utils::SshRemoteProcessRunner *installer;
Utils::SshRemoteProcessRunner *killProcess;
};
} // namespace Internal
@@ -70,14 +71,15 @@ void AbstractRemoteLinuxPackageInstaller::installPackage(const SshConnection::Pt
&& !d->isRunning, return);
prepareInstallation();
d->installer = SshRemoteProcessRunner::create(connection);
connect(d->installer.data(), SIGNAL(connectionError(Utils::SshError)),
delete d->installer;
d->installer = new SshRemoteProcessRunner(connection, this);
connect(d->installer, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(d->installer.data(), SIGNAL(processOutputAvailable(QByteArray)),
connect(d->installer, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleInstallerOutput(QByteArray)));
connect(d->installer.data(), SIGNAL(processErrorOutputAvailable(QByteArray)),
connect(d->installer, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleInstallerErrorOutput(QByteArray)));
connect(d->installer.data(), SIGNAL(processClosed(int)), SLOT(handleInstallationFinished(int)));
connect(d->installer, SIGNAL(processClosed(int)), SLOT(handleInstallationFinished(int)));
QString cmdLine = installCommandLine(packageFilePath);
if (removePackageFile)
@@ -91,9 +93,9 @@ void AbstractRemoteLinuxPackageInstaller::cancelInstallation()
QTC_ASSERT(d->installer && d->installer->connection()->state() == SshConnection::Connected
&& d->isRunning, return);
const SshRemoteProcessRunner::Ptr killProcess
= SshRemoteProcessRunner::create(d->installer->connection());
killProcess->run(cancelInstallationCommandLine().toUtf8());
delete d->killProcess;
d->killProcess = new SshRemoteProcessRunner(d->installer->connection(), this);
d->killProcess->run(cancelInstallationCommandLine().toUtf8());
setFinished();
}
@@ -134,8 +136,9 @@ void AbstractRemoteLinuxPackageInstaller::handleInstallerErrorOutput(const QByte
void AbstractRemoteLinuxPackageInstaller::setFinished()
{
disconnect(d->installer.data(), 0, this, 0);
d->installer.clear();
disconnect(d->installer, 0, this, 0);
delete d->installer;
d->installer = 0;
d->isRunning = false;
}

View File

@@ -52,13 +52,15 @@ class AbstractRemoteLinuxProcessListPrivate
public:
AbstractRemoteLinuxProcessListPrivate(const LinuxDeviceConfiguration::ConstPtr &devConf)
: deviceConfiguration(devConf),
process(SshRemoteProcessRunner::create(devConf->sshParameters())),
process(new SshRemoteProcessRunner(devConf->sshParameters())),
state(Inactive)
{
}
~AbstractRemoteLinuxProcessListPrivate() { delete process; }
const LinuxDeviceConfiguration::ConstPtr deviceConfiguration;
const SshRemoteProcessRunner::Ptr process;
SshRemoteProcessRunner * const process;
QList<AbstractRemoteLinuxProcessList::RemoteProcess> remoteProcesses;
QByteArray remoteStdout;
QByteArray remoteStderr;
@@ -204,13 +206,13 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus)
void AbstractRemoteLinuxProcessList::startProcess(const QString &cmdLine)
{
connect(d->process.data(), SIGNAL(connectionError(Utils::SshError)),
connect(d->process, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(d->process.data(), SIGNAL(processOutputAvailable(QByteArray)),
connect(d->process, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleRemoteStdOut(QByteArray)));
connect(d->process.data(), SIGNAL(processErrorOutputAvailable(QByteArray)),
connect(d->process, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleRemoteStdErr(QByteArray)));
connect(d->process.data(), SIGNAL(processClosed(int)),
connect(d->process, SIGNAL(processClosed(int)),
SLOT(handleRemoteProcessFinished(int)));
d->remoteStdout.clear();
d->remoteStderr.clear();
@@ -220,7 +222,7 @@ void AbstractRemoteLinuxProcessList::startProcess(const QString &cmdLine)
void AbstractRemoteLinuxProcessList::setFinished()
{
disconnect(d->process.data(), 0, this, 0);
disconnect(d->process, 0, this, 0);
d->state = Inactive;
}

View File

@@ -45,14 +45,14 @@ namespace Internal {
class RemoteLinuxUsedPortsGathererPrivate
{
public:
RemoteLinuxUsedPortsGathererPrivate() : running(false) {}
RemoteLinuxUsedPortsGathererPrivate() : procRunner(0), running(false) {}
SshRemoteProcessRunner::Ptr procRunner;
SshRemoteProcessRunner *procRunner;
PortList portsToCheck;
QList<int> usedPorts;
QByteArray remoteStdout;
QByteArray remoteStderr;
bool running;
bool running; // TODO: Redundant due to being in sync with procRunner?
};
} // namespace Internal
@@ -78,14 +78,13 @@ void RemoteLinuxUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connec
d->usedPorts.clear();
d->remoteStdout.clear();
d->remoteStderr.clear();
d->procRunner = SshRemoteProcessRunner::create(connection);
connect(d->procRunner.data(), SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(d->procRunner.data(), SIGNAL(processClosed(int)),
SLOT(handleProcessClosed(int)));
connect(d->procRunner.data(), SIGNAL(processOutputAvailable(QByteArray)),
delete d->procRunner;
d->procRunner = new SshRemoteProcessRunner(connection, this);
connect(d->procRunner, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError()));
connect(d->procRunner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
connect(d->procRunner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleRemoteStdOut(QByteArray)));
connect(d->procRunner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)),
connect(d->procRunner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleRemoteStdErr(QByteArray)));
QString procFilePath;
int addressLength;

View File

@@ -44,7 +44,8 @@ namespace Internal {
class SshKeyDeployerPrivate
{
public:
SshRemoteProcessRunner::Ptr deployProcess;
SshKeyDeployerPrivate() : deployProcess(0) {}
SshRemoteProcessRunner *deployProcess;
};
} // namespace Internal
@@ -64,7 +65,8 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams,
const QString &keyFilePath)
{
cleanup();
d->deployProcess = SshRemoteProcessRunner::create(sshParams);
delete d->deployProcess;
d->deployProcess = new SshRemoteProcessRunner(sshParams, this);
Utils::FileReader reader;
if (!reader.fetch(keyFilePath)) {
@@ -72,10 +74,9 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams,
return;
}
connect(d->deployProcess.data(), SIGNAL(connectionError(Utils::SshError)), this,
connect(d->deployProcess, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionFailure()));
connect(d->deployProcess.data(), SIGNAL(processClosed(int)), this,
SLOT(handleKeyUploadFinished(int)));
connect(d->deployProcess, SIGNAL(processClosed(int)), SLOT(handleKeyUploadFinished(int)));
const QByteArray command = "test -d .ssh "
"|| mkdir .ssh && chmod 0700 .ssh && echo '"
+ reader.data() + "' >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys";
@@ -117,8 +118,9 @@ void SshKeyDeployer::stopDeployment()
void SshKeyDeployer::cleanup()
{
if (d->deployProcess) {
disconnect(d->deployProcess.data(), 0, this, 0);
d->deployProcess.clear();
disconnect(d->deployProcess, 0, this, 0);
delete d->deployProcess;
d->deployProcess = 0;
}
}

View File

@@ -53,10 +53,7 @@ namespace Internal {
class StartGdbServerDialogPrivate
{
public:
StartGdbServerDialogPrivate()
: processList(0)
{}
StartGdbServerDialogPrivate() : processList(0), runner(0) {}
LinuxDeviceConfiguration::ConstPtr currentDevice() const
{
@@ -68,7 +65,7 @@ public:
QSortFilterProxyModel proxyModel;
Ui::StartGdbServerDialog ui;
RemoteLinuxUsedPortsGatherer gatherer;
Utils::SshRemoteProcessRunner::Ptr runner;
Utils::SshRemoteProcessRunner *runner;
};
} // namespace Internal
@@ -241,17 +238,16 @@ void StartGdbServerDialog::handleProcessClosed(int status)
void StartGdbServerDialog::startGdbServerOnPort(int port, int pid)
{
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
d->runner = Utils::SshRemoteProcessRunner::create(device->sshParameters());
connect(d->runner.data(), SIGNAL(connectionError(Utils::SshError)),
delete d->runner;
d->runner = new Utils::SshRemoteProcessRunner(device->sshParameters(), this);
connect(d->runner, SIGNAL(connectionError(Utils::SshError)),
SLOT(handleConnectionError()));
connect(d->runner.data(), SIGNAL(processStarted()),
SLOT(handleProcessStarted()));
connect(d->runner.data(), SIGNAL(processOutputAvailable(QByteArray)),
connect(d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted()));
connect(d->runner, SIGNAL(processOutputAvailable(QByteArray)),
SLOT(handleProcessOutputAvailable(QByteArray)));
connect(d->runner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)),
connect(d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleProcessErrorOutput(QByteArray)));
connect(d->runner.data(), SIGNAL(processClosed(int)),
SLOT(handleProcessClosed(int)));
connect(d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
QByteArray cmd = "/usr/bin/gdbserver --attach localhost:"
+ QByteArray::number(port) + " " + QByteArray::number(pid);