summaryrefslogtreecommitdiffstats
path: root/api/logic/launch
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic/launch')
-rw-r--r--api/logic/launch/LaunchStep.h2
-rw-r--r--api/logic/launch/LaunchTask.cpp20
-rw-r--r--api/logic/launch/LaunchTask.h3
3 files changed, 23 insertions, 2 deletions
diff --git a/api/logic/launch/LaunchStep.h b/api/logic/launch/LaunchStep.h
index ea472c0d..4df4673c 100644
--- a/api/logic/launch/LaunchStep.h
+++ b/api/logic/launch/LaunchStep.h
@@ -42,6 +42,8 @@ signals:
public slots:
virtual void proceed() {};
+ // called in the opposite order than the Task launch(), used to clean up or otherwise undo things after the launch ends
+ virtual void finalize() {};
protected: /* data */
LaunchTask *m_parent;
diff --git a/api/logic/launch/LaunchTask.cpp b/api/logic/launch/LaunchTask.cpp
index a006e519..8b9da398 100644
--- a/api/logic/launch/LaunchTask.cpp
+++ b/api/logic/launch/LaunchTask.cpp
@@ -88,7 +88,7 @@ void LaunchTask::onStepFinished()
// end?
if(currentStep == m_steps.size() - 1)
{
- emitSucceeded();
+ finalizeSteps(true, QString());
}
else
{
@@ -99,7 +99,23 @@ void LaunchTask::onStepFinished()
}
else
{
- emitFailed(step->failReason());
+ finalizeSteps(false, step->failReason());
+ }
+}
+
+void LaunchTask::finalizeSteps(bool successful, const QString& error)
+{
+ for(auto step = currentStep; step >= 0; step--)
+ {
+ m_steps[step]->finalize();
+ }
+ if(successful)
+ {
+ emitSucceeded();
+ }
+ else
+ {
+ emitFailed(error);
}
}
diff --git a/api/logic/launch/LaunchTask.h b/api/logic/launch/LaunchTask.h
index f2fb3a2c..981e25cf 100644
--- a/api/logic/launch/LaunchTask.h
+++ b/api/logic/launch/LaunchTask.h
@@ -109,6 +109,9 @@ public slots:
void onStepFinished();
void onProgressReportingRequested();
+private: /*methods */
+ void finalizeSteps(bool successful, const QString & error);
+
protected: /* data */
InstancePtr m_instance;
shared_qobject_ptr<LogModel> m_logModel;