Maemo: Don't run program if deployment has been canceled by user.

Reviewed-by: kh1
This commit is contained in:
ck
2010-04-13 12:03:32 +02:00
parent e9be9a0d57
commit 781bdd2441
2 changed files with 34 additions and 17 deletions

View File

@@ -68,11 +68,25 @@ AbstractMaemoRunControl::~AbstractMaemoRunControl()
{ {
} }
void AbstractMaemoRunControl::start()
{
m_stoppedByUser = false;
startInternal();
}
void AbstractMaemoRunControl::stop()
{
m_stoppedByUser = true;
stopInternal();
}
void AbstractMaemoRunControl::startDeployment(bool forDebugging) void AbstractMaemoRunControl::startDeployment(bool forDebugging)
{ {
QTC_ASSERT(runConfig, return); QTC_ASSERT(runConfig, return);
if (devConfig.isValid()) { if (m_stoppedByUser) {
handleDeploymentFinished(false);
} else if (devConfig.isValid()) {
m_deployables.clear(); m_deployables.clear();
if (runConfig->currentlyNeedsDeployment(devConfig.host)) { if (runConfig->currentlyNeedsDeployment(devConfig.host)) {
m_deployables.append(Deployable(executableFileName(), m_deployables.append(Deployable(executableFileName(),
@@ -184,14 +198,17 @@ void AbstractMaemoRunControl::kill(const QStringList &apps)
void AbstractMaemoRunControl::deployProcessFinished() void AbstractMaemoRunControl::deployProcessFinished()
{ {
const bool success = !m_sshDeployer->hasError(); const bool success = !m_sshDeployer->hasError();
if (success) { if (m_stoppedByUser) {
emit addToOutputWindow(this, tr("Deployment canceled by user."));
m_progress.reportCanceled();
} else if (success) {
emit addToOutputWindow(this, tr("Deployment finished.")); emit addToOutputWindow(this, tr("Deployment finished."));
} else { } else {
handleError(tr("Deployment failed: %1").arg(m_sshDeployer->error())); handleError(tr("Deployment failed: %1").arg(m_sshDeployer->error()));
m_progress.reportCanceled(); m_progress.reportCanceled();
} }
m_progress.reportFinished(); m_progress.reportFinished();
handleDeploymentFinished(success); handleDeploymentFinished(success && !m_stoppedByUser);
} }
const QString AbstractMaemoRunControl::executableOnHost() const const QString AbstractMaemoRunControl::executableOnHost() const
@@ -264,9 +281,8 @@ MaemoRunControl::~MaemoRunControl()
stop(); stop();
} }
void MaemoRunControl::start() void MaemoRunControl::startInternal()
{ {
m_stoppedByUser = false;
startDeployment(false); startDeployment(false);
} }
@@ -310,12 +326,10 @@ void MaemoRunControl::executionFinished()
emit finished(); emit finished();
} }
void MaemoRunControl::stop() void MaemoRunControl::stopInternal()
{ {
if (!isRunning()) if (!isRunning())
return; return;
m_stoppedByUser = true;
if (isDeploying()) { if (isDeploying()) {
stopDeployment(); stopDeployment();
} else { } else {
@@ -362,7 +376,7 @@ MaemoDebugRunControl::~MaemoDebugRunControl()
debuggingFinished(); debuggingFinished();
} }
void MaemoDebugRunControl::start() void MaemoDebugRunControl::startInternal()
{ {
startDeployment(true); startDeployment(true);
} }
@@ -430,7 +444,7 @@ void MaemoDebugRunControl::startDebugging()
m_debuggerManager->startNewDebugger(m_startParams); m_debuggerManager->startNewDebugger(m_startParams);
} }
void MaemoDebugRunControl::stop() void MaemoDebugRunControl::stopInternal()
{ {
if (!isRunning()) if (!isRunning())
return; return;

View File

@@ -68,6 +68,8 @@ public:
protected: protected:
virtual bool isRunning() const; virtual bool isRunning() const;
virtual void start();
virtual void stop();
void startDeployment(bool forDebugging); void startDeployment(bool forDebugging);
void deploy(); void deploy();
@@ -90,8 +92,11 @@ private slots:
protected: protected:
MaemoRunConfiguration *runConfig; // TODO this pointer can be invalid MaemoRunConfiguration *runConfig; // TODO this pointer can be invalid
const MaemoDeviceConfig devConfig; const MaemoDeviceConfig devConfig;
bool m_stoppedByUser;
private: private:
virtual void startInternal()=0;
virtual void stopInternal()=0;
virtual void handleDeploymentFinished(bool success)=0; virtual void handleDeploymentFinished(bool success)=0;
virtual void handleExecutionAboutToStart(const MaemoSshRunner *runner)=0; virtual void handleExecutionAboutToStart(const MaemoSshRunner *runner)=0;
void kill(const QStringList &apps); void kill(const QStringList &apps);
@@ -119,19 +124,17 @@ class MaemoRunControl : public AbstractMaemoRunControl
public: public:
explicit MaemoRunControl(ProjectExplorer::RunConfiguration *runConfiguration); explicit MaemoRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
~MaemoRunControl(); ~MaemoRunControl();
void start();
void stop();
private slots: private slots:
void executionFinished(); void executionFinished();
void handleRemoteOutput(const QString &output); void handleRemoteOutput(const QString &output);
private: private:
virtual void startInternal();
virtual void stopInternal();
virtual void handleDeploymentFinished(bool success); virtual void handleDeploymentFinished(bool success);
virtual void handleExecutionAboutToStart(const MaemoSshRunner *runner); virtual void handleExecutionAboutToStart(const MaemoSshRunner *runner);
void startExecution(); void startExecution();
bool m_stoppedByUser;
}; };
class MaemoDebugRunControl : public AbstractMaemoRunControl class MaemoDebugRunControl : public AbstractMaemoRunControl
@@ -140,16 +143,16 @@ class MaemoDebugRunControl : public AbstractMaemoRunControl
public: public:
explicit MaemoDebugRunControl(ProjectExplorer::RunConfiguration *runConfiguration); explicit MaemoDebugRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
~MaemoDebugRunControl(); ~MaemoDebugRunControl();
void start();
void stop();
bool isRunning() const; bool isRunning() const;
Q_SLOT void debuggingFinished();
private slots: private slots:
void gdbServerStarted(const QString &output); void gdbServerStarted(const QString &output);
void debuggerOutput(const QString &output); void debuggerOutput(const QString &output);
void debuggingFinished();
private: private:
virtual void startInternal();
virtual void stopInternal();
virtual void handleDeploymentFinished(bool success); virtual void handleDeploymentFinished(bool success);
virtual void handleExecutionAboutToStart(const MaemoSshRunner *runner); virtual void handleExecutionAboutToStart(const MaemoSshRunner *runner);