forked from qt-creator/qt-creator
Maemo: Kill old instances before deploying the application.
Reviewed-by: kh1
This commit is contained in:
@@ -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,16 +175,16 @@ void AbstractMaemoRunControl::handleFileCopied()
|
||||
m_progress.setProgressValue(m_progress.progressValue() + 1);
|
||||
}
|
||||
|
||||
void AbstractMaemoRunControl::stopDeployment()
|
||||
{
|
||||
m_sshDeployer->stop();
|
||||
}
|
||||
|
||||
bool AbstractMaemoRunControl::isDeploying() const
|
||||
{
|
||||
return m_sshDeployer && m_sshDeployer->isRunning();
|
||||
}
|
||||
|
||||
bool AbstractMaemoRunControl::isCleaning() const
|
||||
{
|
||||
return m_initialCleaner && m_initialCleaner->isRunning();
|
||||
}
|
||||
|
||||
void AbstractMaemoRunControl::startExecution()
|
||||
{
|
||||
m_sshRunner.reset(new MaemoSshRunner(m_devConfig, remoteCall()));
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user