Commit 18a134ec authored by ck's avatar ck
Browse files

Maemo: Kill old instances before deploying the application.

Reviewed-by: kh1
parent 44ce228a
......@@ -72,18 +72,43 @@ void AbstractMaemoRunControl::start()
{
m_stoppedByUser = false;
emit started();
startInternal();
startInitialCleanup();
}
void AbstractMaemoRunControl::startInitialCleanup()
{
emit addToOutputWindow(this, tr("Cleaning up remote leftovers first ..."));
const QStringList appsToKill
= QStringList() << executableFileName() << QLatin1String("gdbserver");
killRemoteProcesses(appsToKill, true);
}
void AbstractMaemoRunControl::stop()
{
m_stoppedByUser = true;
if (isDeploying())
stopDeployment();
if (isCleaning())
m_initialCleaner->stop();
else if (isDeploying())
m_sshDeployer->stop();
else
stopInternal();
}
void AbstractMaemoRunControl::handleInitialCleanupFinished()
{
if (m_stoppedByUser) {
emit addToOutputWindow(this, tr("Initial cleanup canceled by user."));
emit finished();
} else if (m_initialCleaner->hasError()) {
handleError(tr("Error running initial cleanup: %1.")
.arg(m_initialCleaner->error()));
emit finished();
} else {
emit addToOutputWindow(this, tr("Initial cleanup done."));
startInternal();
}
}
void AbstractMaemoRunControl::startDeployment(bool forDebugging)
{
QTC_ASSERT(m_runConfig, return);
......@@ -150,14 +175,14 @@ void AbstractMaemoRunControl::handleFileCopied()
m_progress.setProgressValue(m_progress.progressValue() + 1);
}
void AbstractMaemoRunControl::stopDeployment()
bool AbstractMaemoRunControl::isDeploying() const
{
m_sshDeployer->stop();
return m_sshDeployer && m_sshDeployer->isRunning();
}
bool AbstractMaemoRunControl::isDeploying() const
bool AbstractMaemoRunControl::isCleaning() const
{
return m_sshDeployer && m_sshDeployer->isRunning();
return m_initialCleaner && m_initialCleaner->isRunning();
}
void AbstractMaemoRunControl::startExecution()
......@@ -183,11 +208,12 @@ void AbstractMaemoRunControl::stopRunning(bool forDebugging)
QStringList apps(executableFileName());
if (forDebugging)
apps << QLatin1String("gdbserver");
kill(apps);
killRemoteProcesses(apps, false);
}
}
void AbstractMaemoRunControl::kill(const QStringList &apps)
void AbstractMaemoRunControl::killRemoteProcesses(const QStringList &apps,
bool initialCleanup)
{
QString niceKill;
QString brutalKill;
......@@ -197,8 +223,13 @@ void AbstractMaemoRunControl::kill(const QStringList &apps)
}
const QString remoteCall
= niceKill + QLatin1String("sleep 1; ") + brutalKill;
m_sshStopper.reset(new MaemoSshRunner(m_devConfig, remoteCall));
m_sshStopper->start();
QScopedPointer<MaemoSshRunner> &runner
= initialCleanup ? m_initialCleaner : m_sshStopper;
runner.reset(new MaemoSshRunner(m_devConfig, remoteCall));
if (initialCleanup)
connect(runner.data(), SIGNAL(finished()),
this, SLOT(handleInitialCleanupFinished()));
runner->start();
}
void AbstractMaemoRunControl::handleDeployThreadFinished()
......
......@@ -73,7 +73,6 @@ protected:
void startDeployment(bool forDebugging);
void deploy();
void stopDeployment();
void stopRunning(bool forDebugging);
void startExecution();
void handleError(const QString &errString);
......@@ -86,6 +85,7 @@ protected:
const QStringList options() const;
private slots:
virtual void handleRemoteOutput(const QString &output)=0;
void handleInitialCleanupFinished();
void handleDeployThreadFinished();
void handleRunThreadFinished();
void handleFileCopied();
......@@ -98,13 +98,16 @@ private:
virtual void startInternal()=0;
virtual void stopInternal()=0;
virtual QString remoteCall() const=0;
void kill(const QStringList &apps);
void startInitialCleanup();
void killRemoteProcesses(const QStringList &apps, bool initialCleanup);
bool isCleaning() const;
bool isDeploying() const;
QFutureInterface<void> m_progress;
QScopedPointer<MaemoSshDeployer> m_sshDeployer;
QScopedPointer<MaemoSshRunner> m_sshRunner;
QScopedPointer<MaemoSshRunner> m_sshStopper;
QScopedPointer<MaemoSshRunner> m_initialCleaner;
bool m_stoppedByUser;
struct Deployable
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment