summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2017-02-08 18:17:43 +0100
committerAleix Pol <[email protected]>2017-02-08 18:56:45 +0100
commit3ea813f582910791251f040a9bd1809866ace123 (patch)
tree831ecb2eb0a20af2df414fe6e8f8dc3a127f319f
parentcd298256d6bb59b5d2dc804acf39ca131feec2e0 (diff)
Also clean-up transactions that fail
-rw-r--r--libdiscover/backends/FlatpakBackend/FlatpakTransaction.cpp44
-rw-r--r--libdiscover/backends/FlatpakBackend/FlatpakTransaction.h2
2 files changed, 22 insertions, 24 deletions
diff --git a/libdiscover/backends/FlatpakBackend/FlatpakTransaction.cpp b/libdiscover/backends/FlatpakBackend/FlatpakTransaction.cpp
index b8a574f..ac17c1b 100644
--- a/libdiscover/backends/FlatpakBackend/FlatpakTransaction.cpp
+++ b/libdiscover/backends/FlatpakBackend/FlatpakTransaction.cpp
@@ -64,9 +64,7 @@ FlatpakTransaction::FlatpakTransaction(FlatpakInstallation* installation, Flatpa
FlatpakTransaction::~FlatpakTransaction()
{
delete m_appJob;
- if (m_runtimeJob) {
- delete m_runtimeJob;
- }
+ delete m_runtimeJob;
}
void FlatpakTransaction::cancel()
@@ -102,8 +100,8 @@ void FlatpakTransaction::onAppJobFinished(bool success)
m_appJobFinished = true;
m_appJobProgress = 100;
- if (success && m_runtimeJobFinished) {
- finishTransaction();
+ if (m_runtimeJobFinished) {
+ finishTransaction(success);
}
}
@@ -119,8 +117,8 @@ void FlatpakTransaction::onRuntimeJobFinished(bool success)
m_runtimeJobFinished = true;
m_runtimeJobProgress = 100;
- if (success && m_appJobFinished) {
- finishTransaction();
+ if (m_appJobFinished) {
+ finishTransaction(success);
}
}
@@ -140,24 +138,24 @@ void FlatpakTransaction::updateProgress()
}
}
-void FlatpakTransaction::finishTransaction()
+void FlatpakTransaction::finishTransaction(bool success)
{
setStatus(DoneStatus);
- AbstractResource::State newState = AbstractResource::None;
- switch(role()) {
- case InstallRole:
- case ChangeAddonsRole:
- newState = AbstractResource::Installed;
- break;
- case RemoveRole:
- newState = AbstractResource::None;
- break;
- }
- m_app->setState(newState);
- if (m_runtime && role() == InstallRole) {
- m_runtime->setState(newState);
+ if (success) {
+ AbstractResource::State newState = AbstractResource::None;
+ switch(role()) {
+ case InstallRole:
+ case ChangeAddonsRole:
+ newState = AbstractResource::Installed;
+ break;
+ case RemoveRole:
+ newState = AbstractResource::None;
+ break;
+ }
+ m_app->setState(newState);
+ if (m_runtime && role() == InstallRole) {
+ m_runtime->setState(newState);
+ }
}
- // m_app->setAddons(addons());
TransactionModel::global()->removeTransaction(this);
- deleteLater();
}
diff --git a/libdiscover/backends/FlatpakBackend/FlatpakTransaction.h b/libdiscover/backends/FlatpakBackend/FlatpakTransaction.h
index 8474e9a..7f7d6a5 100644
--- a/libdiscover/backends/FlatpakBackend/FlatpakTransaction.h
+++ b/libdiscover/backends/FlatpakBackend/FlatpakTransaction.h
@@ -51,7 +51,7 @@ public Q_SLOTS:
void onAppJobProgressChanged(int progress);
void onRuntimeJobFinished(bool success);
void onRuntimeJobProgressChanged(int progress);
- void finishTransaction();
+ void finishTransaction(bool success);
void start();
private: