diff --git a/src/libs/utils/ssh/sshremoteprocessrunner.cpp b/src/libs/utils/ssh/sshremoteprocessrunner.cpp index 6a751cc37e7..d774f4caae0 100644 --- a/src/libs/utils/ssh/sshremoteprocessrunner.cpp +++ b/src/libs/utils/ssh/sshremoteprocessrunner.cpp @@ -234,24 +234,16 @@ void SshRemoteProcessRunnerPrivate::assertState(State allowedState, } // namespace Internal -SshRemoteProcessRunner::Ptr SshRemoteProcessRunner::create(const SshConnectionParameters ¶ms) -{ - return SshRemoteProcessRunner::Ptr(new SshRemoteProcessRunner(params)); -} - -SshRemoteProcessRunner::Ptr SshRemoteProcessRunner::create(const SshConnection::Ptr &connection) -{ - return SshRemoteProcessRunner::Ptr(new SshRemoteProcessRunner(connection)); -} - -SshRemoteProcessRunner::SshRemoteProcessRunner(const SshConnectionParameters ¶ms) - : d(new Internal::SshRemoteProcessRunnerPrivate(params, this)) +SshRemoteProcessRunner::SshRemoteProcessRunner(const SshConnectionParameters ¶ms, + 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(); } diff --git a/src/libs/utils/ssh/sshremoteprocessrunner.h b/src/libs/utils/ssh/sshremoteprocessrunner.h index 58ad254c6fb..0cd54192636 100644 --- a/src/libs/utils/ssh/sshremoteprocessrunner.h +++ b/src/libs/utils/ssh/sshremoteprocessrunner.h @@ -46,10 +46,8 @@ class QTCREATOR_UTILS_EXPORT SshRemoteProcessRunner : public QObject Q_OBJECT public: - typedef QSharedPointer Ptr; - - static Ptr create(const SshConnectionParameters ¶ms); - static Ptr create(const SshConnection::Ptr &connection); + SshRemoteProcessRunner(const SshConnectionParameters ¶ms, 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 ¶ms); - SshRemoteProcessRunner(const SshConnection::Ptr &connection); void init(); Internal::SshRemoteProcessRunnerPrivate *d; diff --git a/src/plugins/debugger/lldb/lldbenginehost.cpp b/src/plugins/debugger/lldb/lldbenginehost.cpp index edc4107117d..93607834120 100644 --- a/src/plugins/debugger/lldb/lldbenginehost.cpp +++ b/src/plugins/debugger/lldb/lldbenginehost.cpp @@ -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(); diff --git a/src/plugins/debugger/lldb/lldbenginehost.h b/src/plugins/debugger/lldb/lldbenginehost.h index 52483a805c3..e2aec420268 100644 --- a/src/plugins/debugger/lldb/lldbenginehost.h +++ b/src/plugins/debugger/lldb/lldbenginehost.h @@ -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 buckets; @@ -75,7 +76,7 @@ public: private: QProcess *m_guestProcess; - Utils::SshRemoteProcessRunner::Ptr m_ssh; + Utils::SshRemoteProcessRunner *m_ssh; protected: void nuke(); private slots: diff --git a/src/plugins/madde/maddedevicetester.cpp b/src/plugins/madde/maddedevicetester.cpp index 120a465ba0c..24e5c68b1c5 100644 --- a/src/plugins/madde/maddedevicetester.cpp +++ b/src/plugins/madde/maddedevicetester.cpp @@ -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); } diff --git a/src/plugins/madde/maddedevicetester.h b/src/plugins/madde/maddedevicetester.h index 41856c21990..409015662ae 100644 --- a/src/plugins/madde/maddedevicetester.h +++ b/src/plugins/madde/maddedevicetester.h @@ -73,7 +73,7 @@ private: RemoteLinux::GenericLinuxDeviceTester * const m_genericTester; State m_state; TestResult m_result; - QSharedPointer m_processRunner; + Utils::SshRemoteProcessRunner *m_processRunner; QSharedPointer m_deviceConfiguration; QByteArray m_stdout; QByteArray m_stderr; diff --git a/src/plugins/madde/maemopublisherfremantlefree.cpp b/src/plugins/madde/maemopublisherfremantlefree.cpp index a0dbe99bc43..27a25bce6e6 100644 --- a/src/plugins/madde/maemopublisherfremantlefree.cpp +++ b/src/plugins/madde/maemopublisherfremantlefree.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -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; diff --git a/src/plugins/madde/maemopublisherfremantlefree.h b/src/plugins/madde/maemopublisherfremantlefree.h index b300fc3126a..dbe671c021d 100644 --- a/src/plugins/madde/maemopublisherfremantlefree.h +++ b/src/plugins/madde/maemopublisherfremantlefree.h @@ -32,7 +32,7 @@ #ifndef MAEMOPUBLISHERFREMANTLEFREE_H #define MAEMOPUBLISHERFREMANTLEFREE_H -#include +#include #include #include @@ -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 m_uploader; + Utils::SshRemoteProcessRunner *m_uploader; QByteArray m_scpOutput; QList m_filesToUpload; QString m_resultString; diff --git a/src/plugins/madde/maemoremotecopyfacility.cpp b/src/plugins/madde/maemoremotecopyfacility.cpp index 1776fa8ccd4..4179962f1b1 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_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; } diff --git a/src/plugins/madde/maemoremotecopyfacility.h b/src/plugins/madde/maemoremotecopyfacility.h index c2ee128dc79..367238c4b55 100644 --- a/src/plugins/madde/maemoremotecopyfacility.h +++ b/src/plugins/madde/maemoremotecopyfacility.h @@ -81,11 +81,11 @@ private: void copyNextFile(); void setFinished(); - QSharedPointer m_copyRunner; + Utils::SshRemoteProcessRunner *m_copyRunner; QSharedPointer m_devConf; QList m_deployables; QString m_mountPoint; - bool m_isCopying; + bool m_isCopying; // TODO: Redundant due to being in sync with m_copyRunner? }; } // namespace Internal diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp index 18c7ba8cdf9..a197e380acc 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp @@ -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(); } diff --git a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp index ab6bdc7fc61..05ca33cd7a8 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp @@ -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()) { diff --git a/src/plugins/remotelinux/remotelinuxenvironmentreader.h b/src/plugins/remotelinux/remotelinuxenvironmentreader.h index ca26b537f8d..87aa1dccbfa 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentreader.h +++ b/src/plugins/remotelinux/remotelinuxenvironmentreader.h @@ -80,7 +80,7 @@ private: Utils::Environment m_env; QSharedPointer m_devConfig; RemoteLinuxRunConfiguration *m_runConfig; - QSharedPointer m_remoteProcessRunner; + Utils::SshRemoteProcessRunner *m_remoteProcessRunner; }; } // namespace Internal diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp index bb9170fe308..d4b22e99a80 100644 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp +++ b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp @@ -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; } diff --git a/src/plugins/remotelinux/remotelinuxprocesslist.cpp b/src/plugins/remotelinux/remotelinuxprocesslist.cpp index 3286799ff61..cbd3b7c4a60 100644 --- a/src/plugins/remotelinux/remotelinuxprocesslist.cpp +++ b/src/plugins/remotelinux/remotelinuxprocesslist.cpp @@ -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 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; } diff --git a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp index 966f0af06a0..5d60987ba67 100644 --- a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp +++ b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp @@ -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 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; diff --git a/src/plugins/remotelinux/sshkeydeployer.cpp b/src/plugins/remotelinux/sshkeydeployer.cpp index 09d5ea625e4..f07d8ee2028 100644 --- a/src/plugins/remotelinux/sshkeydeployer.cpp +++ b/src/plugins/remotelinux/sshkeydeployer.cpp @@ -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; } } diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp index 1d03976fde5..2e4924c5607 100644 --- a/src/plugins/remotelinux/startgdbserverdialog.cpp +++ b/src/plugins/remotelinux/startgdbserverdialog.cpp @@ -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);