2017-11-11 00:38:31 +00:00
|
|
|
#include "MinecraftLoadAndCheck.h"
|
|
|
|
#include "MinecraftInstance.h"
|
|
|
|
#include "ComponentList.h"
|
|
|
|
|
|
|
|
MinecraftLoadAndCheck::MinecraftLoadAndCheck(MinecraftInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::executeTask()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
// add offline metadata load task
|
|
|
|
auto components = m_inst->getComponentList();
|
|
|
|
components->reload(Net::Mode::Offline);
|
|
|
|
m_task = components->getCurrentTask();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
if(!m_task)
|
|
|
|
{
|
|
|
|
emitSucceeded();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
connect(m_task.get(), &Task::succeeded, this, &MinecraftLoadAndCheck::subtaskSucceeded);
|
|
|
|
connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::subtaskFailed);
|
|
|
|
connect(m_task.get(), &Task::progress, this, &MinecraftLoadAndCheck::progress);
|
|
|
|
connect(m_task.get(), &Task::status, this, &MinecraftLoadAndCheck::setStatus);
|
2017-11-11 00:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::subtaskSucceeded()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
if(isFinished())
|
|
|
|
{
|
2018-11-11 22:55:50 +00:00
|
|
|
qCritical() << "MinecraftUpdate: Subtask" << sender() << "succeeded, but work was already done!";
|
2018-07-15 13:51:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
emitSucceeded();
|
2017-11-11 00:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::subtaskFailed(QString error)
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
if(isFinished())
|
|
|
|
{
|
2018-11-11 22:55:50 +00:00
|
|
|
qCritical() << "MinecraftUpdate: Subtask" << sender() << "failed, but work was already done!";
|
2018-07-15 13:51:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
emitFailed(error);
|
2017-11-11 00:38:31 +00:00
|
|
|
}
|