diff options
author | Christian Kandeler <christian.kandeler@nokia.com> | 2011-11-09 14:19:50 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@nokia.com> | 2011-11-09 14:28:49 +0100 |
commit | fd26ab22e9db6075604ffdd7d54ae9b57644590a (patch) | |
tree | 9c39128e3a088fd7baf3584e78b023d12c08405e /src/plugins | |
parent | f9623b5ad69bbe6700b27f0cd8b6191c70994908 (diff) | |
download | qt-creator-fd26ab22e9db6075604ffdd7d54ae9b57644590a.tar.gz |
SSH: Improve SshRemoteProcessRunner API.
It's silly that we fix the connection parameters in the constructor. A
given object of the class, once created, should be able to repeatedly
run any command with any connection.
Change-Id: Ia45b9d5b6f25c25fb46751cdb47cf81877d8f9a9
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/debugger/lldb/lldbenginehost.cpp | 5 | ||||
-rw-r--r-- | src/plugins/madde/maddedevicetester.cpp | 14 | ||||
-rw-r--r-- | src/plugins/madde/maemopublisherfremantlefree.cpp | 8 | ||||
-rw-r--r-- | src/plugins/madde/maemoremotecopyfacility.cpp | 20 | ||||
-rw-r--r-- | src/plugins/madde/maemoremotecopyfacility.h | 1 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp | 10 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxenvironmentreader.cpp | 11 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxpackageinstaller.cpp | 15 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxprocesslist.cpp | 24 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp | 34 | ||||
-rw-r--r-- | src/plugins/remotelinux/sshkeydeployer.cpp | 27 | ||||
-rw-r--r-- | src/plugins/remotelinux/startgdbserverdialog.cpp | 26 |
12 files changed, 84 insertions, 111 deletions
diff --git a/src/plugins/debugger/lldb/lldbenginehost.cpp b/src/plugins/debugger/lldb/lldbenginehost.cpp index 9360783412..6005ac0ce8 100644 --- a/src/plugins/debugger/lldb/lldbenginehost.cpp +++ b/src/plugins/debugger/lldb/lldbenginehost.cpp @@ -151,11 +151,10 @@ LldbEngineHost::LldbEngineHost(const DebuggerStartParameters &startParameters) if (startParameters.startMode == StartRemoteEngine) { m_guestProcess = 0; - Utils::SshRemoteProcessRunner * const runner = - new Utils::SshRemoteProcessRunner(startParameters.connParams); + Utils::SshRemoteProcessRunner * const runner = new Utils::SshRemoteProcessRunner; connect (runner, SIGNAL(connectionError(Utils::SshError)), this, SLOT(sshConnectionError(Utils::SshError))); - runner->run(startParameters.serverStartScript.toUtf8()); + runner->run(startParameters.serverStartScript.toUtf8(), startParameters.connParams); setGuestDevice(new SshIODevice(runner)); } else { m_guestProcess = new QProcess(this); diff --git a/src/plugins/madde/maddedevicetester.cpp b/src/plugins/madde/maddedevicetester.cpp index 24e5c68b1c..2ca4d09425 100644 --- a/src/plugins/madde/maddedevicetester.cpp +++ b/src/plugins/madde/maddedevicetester.cpp @@ -107,8 +107,8 @@ void MaddeDeviceTester::handleGenericTestFinished(TestResult result) return; } - delete m_processRunner; - m_processRunner = new SshRemoteProcessRunner(m_genericTester->connection(), this); + if (!m_processRunner) + m_processRunner = new SshRemoteProcessRunner(this); connect(m_processRunner, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); connect(m_processRunner, SIGNAL(processOutputAvailable(QByteArray)), @@ -129,7 +129,7 @@ void MaddeDeviceTester::handleGenericTestFinished(TestResult result) m_stdout.clear(); m_stderr.clear(); m_state = QtTest; - m_processRunner->run(qtInfoCmd.toUtf8()); + m_processRunner->run(qtInfoCmd.toUtf8(), m_genericTester->connection()->connectionParameters()); } void MaddeDeviceTester::handleConnectionError() @@ -196,7 +196,8 @@ void MaddeDeviceTester::handleQtTestFinished(int exitStatus) emit progressMessage(tr("Checking for connectivity support...")); m_state = MadDeveloperTest; - m_processRunner->run(QString(QLatin1String("test -x") + MaemoGlobal::devrootshPath()).toUtf8()); + m_processRunner->run(QString(QLatin1String("test -x") + MaemoGlobal::devrootshPath()).toUtf8(), + m_genericTester->connection()->connectionParameters()); } void MaddeDeviceTester::handleMadDeveloperTestFinished(int exitStatus) @@ -233,7 +234,8 @@ void MaddeDeviceTester::handleMadDeveloperTestFinished(int exitStatus) emit progressMessage(tr("Checking for QML tooling support...")); m_state = QmlToolingTest; m_processRunner->run(QString(QLatin1String("test -d ") - + QLatin1String(QmlToolingDirectory)).toUtf8()); + + QLatin1String(QmlToolingDirectory)).toUtf8(), + m_genericTester->connection()->connectionParameters()); } void MaddeDeviceTester::handleQmlToolingTestFinished(int exitStatus) @@ -285,8 +287,6 @@ QString MaddeDeviceTester::processedQtLibsList() disconnect(m_genericTester, 0, this, 0); if (m_processRunner) disconnect(m_processRunner, 0, this, 0); - delete m_processRunner; - m_processRunner = 0; emit finished(m_result); } diff --git a/src/plugins/madde/maemopublisherfremantlefree.cpp b/src/plugins/madde/maemopublisherfremantlefree.cpp index 27a25bce6e..db953d4664 100644 --- a/src/plugins/madde/maemopublisherfremantlefree.cpp +++ b/src/plugins/madde/maemopublisherfremantlefree.cpp @@ -385,8 +385,8 @@ void MaemoPublisherFremantleFree::runDpkgBuildPackage() // webmaster refuses to enable SFTP "for security reasons" ... void MaemoPublisherFremantleFree::uploadPackage() { - delete m_uploader; - m_uploader = new SshRemoteProcessRunner(m_sshParams, this); + if (!m_uploader) + m_uploader = new SshRemoteProcessRunner(this); connect(m_uploader, SIGNAL(processStarted()), SLOT(handleScpStarted())); connect(m_uploader, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); @@ -395,7 +395,7 @@ void MaemoPublisherFremantleFree::uploadPackage() SLOT(handleScpStdOut(QByteArray))); emit progressReport(tr("Starting scp ...")); setState(StartingScp); - m_uploader->run("scp -td " + m_remoteDir.toUtf8()); + m_uploader->run("scp -td " + m_remoteDir.toUtf8(), m_sshParams); } void MaemoPublisherFremantleFree::handleScpStarted() @@ -633,8 +633,6 @@ void MaemoPublisherFremantleFree::setState(State newState) // an illegal sequence of bytes? (Probably not, if // we are currently uploading a file.) disconnect(m_uploader, 0, this, 0); - delete m_uploader; - m_uploader = 0; break; default: break; diff --git a/src/plugins/madde/maemoremotecopyfacility.cpp b/src/plugins/madde/maemoremotecopyfacility.cpp index a0dc120015..dd2593ad2a 100644 --- a/src/plugins/madde/maemoremotecopyfacility.cpp +++ b/src/plugins/madde/maemoremotecopyfacility.cpp @@ -46,7 +46,7 @@ namespace Madde { namespace Internal { MaemoRemoteCopyFacility::MaemoRemoteCopyFacility(QObject *parent) : - QObject(parent), m_copyRunner(0), m_isCopying(false) + QObject(parent), m_copyRunner(0), m_killProcess(0), m_isCopying(false) { } @@ -63,8 +63,8 @@ void MaemoRemoteCopyFacility::copyFiles(const SshConnection::Ptr &connection, m_deployables = deployables; m_mountPoint = mountPoint; - delete m_copyRunner; - m_copyRunner = new SshRemoteProcessRunner(connection, this); + if (!m_copyRunner) + m_copyRunner = new SshRemoteProcessRunner(this); connect(m_copyRunner, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); connect(m_copyRunner, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleRemoteStdout(QByteArray))); @@ -80,10 +80,9 @@ void MaemoRemoteCopyFacility::cancel() { Q_ASSERT(m_isCopying); - // TODO: Make member as to not waste memory. - SshRemoteProcessRunner * const killProcess - = new SshRemoteProcessRunner(m_copyRunner->connection(), this); - killProcess->run("pkill cp"); + if (!m_killProcess) + m_killProcess = new SshRemoteProcessRunner(this); + m_killProcess->run("pkill cp", m_devConf->sshParameters()); setFinished(); } @@ -140,19 +139,16 @@ void MaemoRemoteCopyFacility::copyNextFile() #endif QString command = QString::fromLatin1("%1 mkdir -p %3 && %1 cp -a %2 %3") - .arg(MaemoGlobal::remoteSudo(m_devConf->osType(), - m_copyRunner->connection()->connectionParameters().userName), + .arg(MaemoGlobal::remoteSudo(m_devConf->osType(), m_devConf->sshParameters().userName), sourceFilePath, d.remoteDir); emit progress(tr("Copying file '%1' to directory '%2' on the device...") .arg(d.localFilePath, d.remoteDir)); - m_copyRunner->run(command.toUtf8()); + m_copyRunner->run(command.toUtf8(), m_devConf->sshParameters()); } void MaemoRemoteCopyFacility::setFinished() { disconnect(m_copyRunner, 0, this, 0); - delete m_copyRunner; - m_copyRunner = 0; m_deployables.clear(); m_isCopying = false; } diff --git a/src/plugins/madde/maemoremotecopyfacility.h b/src/plugins/madde/maemoremotecopyfacility.h index 367238c4b5..d101ef63da 100644 --- a/src/plugins/madde/maemoremotecopyfacility.h +++ b/src/plugins/madde/maemoremotecopyfacility.h @@ -82,6 +82,7 @@ private: void setFinished(); Utils::SshRemoteProcessRunner *m_copyRunner; + Utils::SshRemoteProcessRunner *m_killProcess; QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> m_devConf; QList<RemoteLinux::DeployableFile> m_deployables; QString m_mountPoint; diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp index a197e380ac..c32ae14e0d 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp @@ -31,6 +31,8 @@ **************************************************************************/ #include "remotelinuxcustomcommanddeployservice.h" +#include "linuxdeviceconfiguration.h" + #include <utils/qtcassert.h> #include <utils/ssh/sshremoteprocessrunner.h> @@ -95,8 +97,8 @@ void RemoteLinuxCustomCommandDeployService::doDeploy() { QTC_ASSERT(d->state == Inactive, handleDeploymentDone()); - delete d->runner; - d->runner = new SshRemoteProcessRunner(connection(), this); + if (!d->runner) + d->runner = new SshRemoteProcessRunner(this); connect(d->runner, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleStdout(QByteArray))); connect(d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)), @@ -105,7 +107,7 @@ void RemoteLinuxCustomCommandDeployService::doDeploy() emit progressMessage(tr("Starting remote command '%1'...").arg(d->commandLine)); d->state = Running; - d->runner->run(d->commandLine.toUtf8()); + d->runner->run(d->commandLine.toUtf8(), deviceConfiguration()->sshParameters()); } void RemoteLinuxCustomCommandDeployService::stopDeployment() @@ -114,8 +116,6 @@ void RemoteLinuxCustomCommandDeployService::stopDeployment() disconnect(d->runner, 0, this, 0); d->runner->process()->closeChannel(); - delete d->runner; - d->runner = 0; d->state = Inactive; handleDeploymentDone(); } diff --git a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp index 05ca33cd7a..9a15d27db7 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp @@ -59,13 +59,8 @@ void RemoteLinuxEnvironmentReader::start(const QString &environmentSetupCommand) if (!m_devConfig) return; m_stop = false; - if (!m_remoteProcessRunner - || m_remoteProcessRunner->connection()->state() != Utils::SshConnection::Connected - || m_remoteProcessRunner->connection()->connectionParameters() != m_devConfig->sshParameters()) { - delete m_remoteProcessRunner; - m_remoteProcessRunner - = new Utils::SshRemoteProcessRunner(m_devConfig->sshParameters(), this); - } + if (!m_remoteProcessRunner) + m_remoteProcessRunner = new Utils::SshRemoteProcessRunner(this); connect(m_remoteProcessRunner, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionFailure())); connect(m_remoteProcessRunner, SIGNAL(processClosed(int)), SLOT(remoteProcessFinished(int))); @@ -76,7 +71,7 @@ void RemoteLinuxEnvironmentReader::start(const QString &environmentSetupCommand) const QByteArray remoteCall = QString(environmentSetupCommand + QLatin1String("; env")).toUtf8(); m_remoteOutput.clear(); - m_remoteProcessRunner->run(remoteCall); + m_remoteProcessRunner->run(remoteCall, m_devConfig->sshParameters()); } void RemoteLinuxEnvironmentReader::stop() diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp index d4b22e99a8..f02d8c417f 100644 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp +++ b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp @@ -71,8 +71,8 @@ void AbstractRemoteLinuxPackageInstaller::installPackage(const SshConnection::Pt && !d->isRunning, return); prepareInstallation(); - delete d->installer; - d->installer = new SshRemoteProcessRunner(connection, this); + if (!d->installer) + d->installer = new SshRemoteProcessRunner(this); connect(d->installer, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); connect(d->installer, SIGNAL(processOutputAvailable(QByteArray)), @@ -84,7 +84,7 @@ void AbstractRemoteLinuxPackageInstaller::installPackage(const SshConnection::Pt QString cmdLine = installCommandLine(packageFilePath); if (removePackageFile) cmdLine += QLatin1String(" && (rm ") + packageFilePath + QLatin1String(" || :)"); - d->installer->run(cmdLine.toUtf8()); + d->installer->run(cmdLine.toUtf8(), connection->connectionParameters()); d->isRunning = true; } @@ -93,9 +93,10 @@ void AbstractRemoteLinuxPackageInstaller::cancelInstallation() QTC_ASSERT(d->installer && d->installer->connection()->state() == SshConnection::Connected && d->isRunning, return); - delete d->killProcess; - d->killProcess = new SshRemoteProcessRunner(d->installer->connection(), this); - d->killProcess->run(cancelInstallationCommandLine().toUtf8()); + if (!d->killProcess) + d->killProcess = new SshRemoteProcessRunner(this); + d->killProcess->run(cancelInstallationCommandLine().toUtf8(), + d->installer->connection()->connectionParameters()); setFinished(); } @@ -137,8 +138,6 @@ void AbstractRemoteLinuxPackageInstaller::handleInstallerErrorOutput(const QByte void AbstractRemoteLinuxPackageInstaller::setFinished() { disconnect(d->installer, 0, this, 0); - delete d->installer; - d->installer = 0; d->isRunning = false; } diff --git a/src/plugins/remotelinux/remotelinuxprocesslist.cpp b/src/plugins/remotelinux/remotelinuxprocesslist.cpp index cbd3b7c4a6..c5f62e363e 100644 --- a/src/plugins/remotelinux/remotelinuxprocesslist.cpp +++ b/src/plugins/remotelinux/remotelinuxprocesslist.cpp @@ -52,15 +52,13 @@ class AbstractRemoteLinuxProcessListPrivate public: AbstractRemoteLinuxProcessListPrivate(const LinuxDeviceConfiguration::ConstPtr &devConf) : deviceConfiguration(devConf), - process(new SshRemoteProcessRunner(devConf->sshParameters())), state(Inactive) { } - ~AbstractRemoteLinuxProcessListPrivate() { delete process; } const LinuxDeviceConfiguration::ConstPtr deviceConfiguration; - SshRemoteProcessRunner * const process; + SshRemoteProcessRunner process; QList<AbstractRemoteLinuxProcessList::RemoteProcess> remoteProcesses; QByteArray remoteStdout; QByteArray remoteStderr; @@ -156,7 +154,7 @@ void AbstractRemoteLinuxProcessList::handleConnectionError() { QTC_ASSERT(d->state != Inactive, return); - emit error(tr("Connection failure: %1").arg(d->process->connection()->errorString())); + emit error(tr("Connection failure: %1").arg(d->process.connection()->errorString())); beginResetModel(); d->remoteProcesses.clear(); endResetModel(); @@ -170,14 +168,14 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus) switch (exitStatus) { case SshRemoteProcess::FailedToStart: d->errorMsg = tr("Error: Remote process failed to start: %1") - .arg(d->process->process()->errorString()); + .arg(d->process.process()->errorString()); break; case SshRemoteProcess::KilledBySignal: d->errorMsg = tr("Error: Remote process crashed: %1") - .arg(d->process->process()->errorString()); + .arg(d->process.process()->errorString()); break; case SshRemoteProcess::ExitedNormally: - if (d->process->process()->exitCode() == 0) { + if (d->process.process()->exitCode() == 0) { if (d->state == Listing) { d->remoteProcesses = buildProcessList(QString::fromUtf8(d->remoteStdout.data(), d->remoteStdout.count())); @@ -206,23 +204,23 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus) void AbstractRemoteLinuxProcessList::startProcess(const QString &cmdLine) { - connect(d->process, SIGNAL(connectionError(Utils::SshError)), + connect(&d->process, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); - connect(d->process, SIGNAL(processOutputAvailable(QByteArray)), + connect(&d->process, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleRemoteStdOut(QByteArray))); - connect(d->process, SIGNAL(processErrorOutputAvailable(QByteArray)), + connect(&d->process, SIGNAL(processErrorOutputAvailable(QByteArray)), SLOT(handleRemoteStdErr(QByteArray))); - connect(d->process, SIGNAL(processClosed(int)), + connect(&d->process, SIGNAL(processClosed(int)), SLOT(handleRemoteProcessFinished(int))); d->remoteStdout.clear(); d->remoteStderr.clear(); d->errorMsg.clear(); - d->process->run(cmdLine.toUtf8()); + d->process.run(cmdLine.toUtf8(), d->deviceConfiguration->sshParameters()); } void AbstractRemoteLinuxProcessList::setFinished() { - disconnect(d->process, 0, this, 0); + disconnect(&d->process, 0, this, 0); d->state = Inactive; } diff --git a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp index 5d60987ba6..e5092f9a0c 100644 --- a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp +++ b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp @@ -45,9 +45,9 @@ namespace Internal { class RemoteLinuxUsedPortsGathererPrivate { public: - RemoteLinuxUsedPortsGathererPrivate() : procRunner(0), running(false) {} + RemoteLinuxUsedPortsGathererPrivate() : running(false) {} - SshRemoteProcessRunner *procRunner; + SshRemoteProcessRunner procRunner; PortList portsToCheck; QList<int> usedPorts; QByteArray remoteStdout; @@ -78,13 +78,11 @@ void RemoteLinuxUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connec d->usedPorts.clear(); d->remoteStdout.clear(); d->remoteStderr.clear(); - 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)), + 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, SIGNAL(processErrorOutputAvailable(QByteArray)), + connect(&d->procRunner, SIGNAL(processErrorOutputAvailable(QByteArray)), SLOT(handleRemoteStdErr(QByteArray))); QString procFilePath; int addressLength; @@ -98,7 +96,10 @@ void RemoteLinuxUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connec const QString command = QString::fromLocal8Bit("sed " "'s/.*: [[:xdigit:]]\\{%1\\}:\\([[:xdigit:]]\\{4\\}\\).*/\\1/g' %2") .arg(addressLength).arg(procFilePath); - d->procRunner->run(command.toUtf8()); + + // TODO: We should not use an SshRemoteProcessRunner here, because we have to check + // for the type of the connection before we can say what the exact command line is. + d->procRunner.run(command.toUtf8(), connection->connectionParameters()); d->running = true; } @@ -107,9 +108,7 @@ void RemoteLinuxUsedPortsGatherer::stop() if (!d->running) return; d->running = false; - disconnect(d->procRunner->connection().data(), 0, this, 0); - if (d->procRunner->process()) - d->procRunner->process()->closeChannel(); + disconnect(&d->procRunner, 0, this, 0); } int RemoteLinuxUsedPortsGatherer::getNextFreePort(PortList *freePorts) const @@ -151,8 +150,7 @@ void RemoteLinuxUsedPortsGatherer::handleConnectionError() { if (!d->running) return; - emit error(tr("Connection error: %1"). - arg(d->procRunner->connection()->errorString())); + emit error(tr("Connection error: %1").arg(d->procRunner.connection()->errorString())); stop(); } @@ -164,18 +162,18 @@ void RemoteLinuxUsedPortsGatherer::handleProcessClosed(int exitStatus) switch (exitStatus) { case SshRemoteProcess::FailedToStart: errMsg = tr("Could not start remote process: %1") - .arg(d->procRunner->process()->errorString()); + .arg(d->procRunner.process()->errorString()); break; case SshRemoteProcess::KilledBySignal: errMsg = tr("Remote process crashed: %1") - .arg(d->procRunner->process()->errorString()); + .arg(d->procRunner.process()->errorString()); break; case SshRemoteProcess::ExitedNormally: - if (d->procRunner->process()->exitCode() == 0) { + if (d->procRunner.process()->exitCode() == 0) { setupUsedPorts(); } else { errMsg = tr("Remote process failed; exit code was %1.") - .arg(d->procRunner->process()->exitCode()); + .arg(d->procRunner.process()->exitCode()); } break; default: diff --git a/src/plugins/remotelinux/sshkeydeployer.cpp b/src/plugins/remotelinux/sshkeydeployer.cpp index f07d8ee202..5bd32846a8 100644 --- a/src/plugins/remotelinux/sshkeydeployer.cpp +++ b/src/plugins/remotelinux/sshkeydeployer.cpp @@ -44,8 +44,7 @@ namespace Internal { class SshKeyDeployerPrivate { public: - SshKeyDeployerPrivate() : deployProcess(0) {} - SshRemoteProcessRunner *deployProcess; + SshRemoteProcessRunner deployProcess; }; } // namespace Internal @@ -65,8 +64,6 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams, const QString &keyFilePath) { cleanup(); - delete d->deployProcess; - d->deployProcess = new SshRemoteProcessRunner(sshParams, this); Utils::FileReader reader; if (!reader.fetch(keyFilePath)) { @@ -74,20 +71,18 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams, return; } - connect(d->deployProcess, SIGNAL(connectionError(Utils::SshError)), + connect(&d->deployProcess, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionFailure())); - connect(d->deployProcess, SIGNAL(processClosed(int)), 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"; - d->deployProcess->run(command); + d->deployProcess.run(command, sshParams); } void SshKeyDeployer::handleConnectionFailure() { - if (!d->deployProcess) - return; - const QString errorMsg = d->deployProcess->connection()->errorString(); + const QString errorMsg = d->deployProcess.connection()->errorString(); cleanup(); emit error(tr("Connection failed: %1").arg(errorMsg)); } @@ -98,11 +93,11 @@ void SshKeyDeployer::handleKeyUploadFinished(int exitStatus) || exitStatus == SshRemoteProcess::KilledBySignal || exitStatus == SshRemoteProcess::ExitedNormally); - if (!d->deployProcess) + if (!d->deployProcess.process()) return; - const int exitCode = d->deployProcess->process()->exitCode(); - const QString errorMsg = d->deployProcess->process()->errorString(); + const int exitCode = d->deployProcess.process()->exitCode(); + const QString errorMsg = d->deployProcess.process()->errorString(); cleanup(); if (exitStatus == SshRemoteProcess::ExitedNormally && exitCode == 0) emit finishedSuccessfully(); @@ -117,11 +112,7 @@ void SshKeyDeployer::stopDeployment() void SshKeyDeployer::cleanup() { - if (d->deployProcess) { - disconnect(d->deployProcess, 0, this, 0); - delete d->deployProcess; - d->deployProcess = 0; - } + disconnect(&d->deployProcess, 0, this, 0); } } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp index 2e4924c560..c41061f24c 100644 --- a/src/plugins/remotelinux/startgdbserverdialog.cpp +++ b/src/plugins/remotelinux/startgdbserverdialog.cpp @@ -53,7 +53,7 @@ namespace Internal { class StartGdbServerDialogPrivate { public: - StartGdbServerDialogPrivate() : processList(0), runner(0) {} + StartGdbServerDialogPrivate() : processList(0) {} LinuxDeviceConfiguration::ConstPtr currentDevice() const { @@ -65,7 +65,7 @@ public: QSortFilterProxyModel proxyModel; Ui::StartGdbServerDialog ui; RemoteLinuxUsedPortsGatherer gatherer; - Utils::SshRemoteProcessRunner *runner; + Utils::SshRemoteProcessRunner runner; }; } // namespace Internal @@ -203,7 +203,7 @@ void StartGdbServerDialog::startGdbServer() void StartGdbServerDialog::handleConnectionError() { d->ui.textBrowser->append(tr("Connection error: %1") - .arg(d->runner->connection()->errorString())); + .arg(d->runner.connection()->errorString())); emit processAborted(); } @@ -238,20 +238,18 @@ void StartGdbServerDialog::handleProcessClosed(int status) void StartGdbServerDialog::startGdbServerOnPort(int port, int pid) { LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); - delete d->runner; - d->runner = new Utils::SshRemoteProcessRunner(device->sshParameters(), this); - connect(d->runner, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); - connect(d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted())); - connect(d->runner, SIGNAL(processOutputAvailable(QByteArray)), - SLOT(handleProcessOutputAvailable(QByteArray))); - connect(d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)), - SLOT(handleProcessErrorOutput(QByteArray))); - connect(d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int))); + connect(&d->runner, SIGNAL(connectionError(Utils::SshError)), + SLOT(handleConnectionError())); + connect(&d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted())); + connect(&d->runner, SIGNAL(processOutputAvailable(QByteArray)), + SLOT(handleProcessOutputAvailable(QByteArray))); + connect(&d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)), + SLOT(handleProcessErrorOutput(QByteArray))); + connect(&d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int))); QByteArray cmd = "/usr/bin/gdbserver --attach localhost:" + QByteArray::number(port) + " " + QByteArray::number(pid); - d->runner->run(cmd); + d->runner.run(cmd, device->sshParameters()); } } // namespace RemoteLinux |