GH-1949 Allow ATLauncher pack downloads to be aborted
This commit is contained in:
parent
d5c4489313
commit
220971fadd
@ -28,7 +28,11 @@ PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString pack,
|
|||||||
|
|
||||||
bool PackInstallTask::abort()
|
bool PackInstallTask::abort()
|
||||||
{
|
{
|
||||||
return true;
|
if(abortable)
|
||||||
|
{
|
||||||
|
return jobPtr->abort();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::executeTask()
|
void PackInstallTask::executeTask()
|
||||||
@ -418,16 +422,19 @@ void PackInstallTask::installConfigs()
|
|||||||
|
|
||||||
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
|
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
|
||||||
{
|
{
|
||||||
|
abortable = false;
|
||||||
jobPtr.reset();
|
jobPtr.reset();
|
||||||
extractConfigs();
|
extractConfigs();
|
||||||
});
|
});
|
||||||
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
||||||
{
|
{
|
||||||
|
abortable = false;
|
||||||
jobPtr.reset();
|
jobPtr.reset();
|
||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
});
|
});
|
||||||
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
||||||
{
|
{
|
||||||
|
abortable = true;
|
||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -576,11 +583,13 @@ void PackInstallTask::downloadMods()
|
|||||||
connect(jobPtr.get(), &NetJob::succeeded, this, &PackInstallTask::onModsDownloaded);
|
connect(jobPtr.get(), &NetJob::succeeded, this, &PackInstallTask::onModsDownloaded);
|
||||||
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
||||||
{
|
{
|
||||||
|
abortable = false;
|
||||||
jobPtr.reset();
|
jobPtr.reset();
|
||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
});
|
});
|
||||||
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
||||||
{
|
{
|
||||||
|
abortable = true;
|
||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -588,6 +597,8 @@ void PackInstallTask::downloadMods()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::onModsDownloaded() {
|
void PackInstallTask::onModsDownloaded() {
|
||||||
|
abortable = false;
|
||||||
|
|
||||||
qDebug() << "PackInstallTask::onModsDownloaded: " << QThread::currentThreadId();
|
qDebug() << "PackInstallTask::onModsDownloaded: " << QThread::currentThreadId();
|
||||||
jobPtr.reset();
|
jobPtr.reset();
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
explicit PackInstallTask(UserInteractionSupport *support, QString pack, QString version);
|
explicit PackInstallTask(UserInteractionSupport *support, QString pack, QString version);
|
||||||
virtual ~PackInstallTask(){}
|
virtual ~PackInstallTask(){}
|
||||||
|
|
||||||
|
bool canAbort() const override { return true; }
|
||||||
bool abort() override;
|
bool abort() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -72,6 +73,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
UserInteractionSupport *m_support;
|
UserInteractionSupport *m_support;
|
||||||
|
|
||||||
|
bool abortable = false;
|
||||||
|
|
||||||
NetJobPtr jobPtr;
|
NetJobPtr jobPtr;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user