summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-07-21 08:49:58 +0200
committerPetr Mrázek <peterix@gmail.com>2017-07-21 08:49:58 +0200
commitbea1b5de5e1b06c40c862366d61218a06c8fdfe1 (patch)
tree25dd898e143bc562e61802346a97fc9f2fed82d2 /api/logic/minecraft
parentc19f6d4dcd0650f5f30c59a907d8022a4c642c8e (diff)
downloadMultiMC-bea1b5de5e1b06c40c862366d61218a06c8fdfe1.tar
MultiMC-bea1b5de5e1b06c40c862366d61218a06c8fdfe1.tar.gz
MultiMC-bea1b5de5e1b06c40c862366d61218a06c8fdfe1.tar.lz
MultiMC-bea1b5de5e1b06c40c862366d61218a06c8fdfe1.tar.xz
MultiMC-bea1b5de5e1b06c40c862366d61218a06c8fdfe1.zip
GH-1929 do not allow non-current update task to affect the update process
Errors are handled by setting a flag and failing on the next call to next()
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r--api/logic/minecraft/onesix/OneSixUpdate.cpp22
-rw-r--r--api/logic/minecraft/onesix/OneSixUpdate.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp
index 07ca5fb2..230877ef 100644
--- a/api/logic/minecraft/onesix/OneSixUpdate.cpp
+++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp
@@ -109,6 +109,11 @@ void OneSixUpdate::next()
emitFailed(tr("Aborted by user."));
return;
}
+ if(m_failed_out_of_order)
+ {
+ emitFailed(m_fail_reason);
+ return;
+ }
m_currentTask ++;
if(m_currentTask > 0)
{
@@ -127,6 +132,7 @@ void OneSixUpdate::next()
// if the task is already finished by the time we look at it, skip it
if(task->isFinished())
{
+ qCritical() << "OneSixUpdate: Skipping finished subtask" << m_currentTask << ":" << task.get();
next();
}
connect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
@@ -147,6 +153,13 @@ void OneSixUpdate::subtaskSucceeded()
qCritical() << "OneSixUpdate: Subtask" << sender() << "succeeded, but work was already done!";
return;
}
+ auto senderTask = QObject::sender();
+ auto currentTask = m_tasks[m_currentTask].get();
+ if(senderTask != currentTask)
+ {
+ qDebug() << "OneSixUpdate: Subtask" << sender() << "succeeded out of order.";
+ return;
+ }
next();
}
@@ -157,6 +170,15 @@ void OneSixUpdate::subtaskFailed(QString error)
qCritical() << "OneSixUpdate: Subtask" << sender() << "failed, but work was already done!";
return;
}
+ auto senderTask = QObject::sender();
+ auto currentTask = m_tasks[m_currentTask].get();
+ if(senderTask != currentTask)
+ {
+ qDebug() << "OneSixUpdate: Subtask" << sender() << "failed out of order.";
+ m_failed_out_of_order = true;
+ m_fail_reason = error;
+ return;
+ }
emitFailed(error);
}
diff --git a/api/logic/minecraft/onesix/OneSixUpdate.h b/api/logic/minecraft/onesix/OneSixUpdate.h
index 6bcfd41a..f879f19e 100644
--- a/api/logic/minecraft/onesix/OneSixUpdate.h
+++ b/api/logic/minecraft/onesix/OneSixUpdate.h
@@ -50,4 +50,6 @@ private:
QString m_preFailure;
int m_currentTask = -1;
bool m_abort = false;
+ bool m_failed_out_of_order = false;
+ QString m_fail_reason;
};