fix: simplify abort handling and add missing emits
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
4b0ceea894
commit
6541570969
@ -91,6 +91,7 @@ void InstanceImportTask::executeTask()
|
|||||||
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
|
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
|
||||||
connect(m_filesNetJob.get(), &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
|
connect(m_filesNetJob.get(), &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
|
||||||
connect(m_filesNetJob.get(), &NetJob::failed, this, &InstanceImportTask::downloadFailed);
|
connect(m_filesNetJob.get(), &NetJob::failed, this, &InstanceImportTask::downloadFailed);
|
||||||
|
connect(m_filesNetJob.get(), &NetJob::aborted, this, &InstanceImportTask::downloadAborted);
|
||||||
|
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start();
|
||||||
}
|
}
|
||||||
@ -113,6 +114,12 @@ void InstanceImportTask::downloadProgressChanged(qint64 current, qint64 total)
|
|||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceImportTask::downloadAborted()
|
||||||
|
{
|
||||||
|
emitAborted();
|
||||||
|
m_filesNetJob.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceImportTask::processZipPack()
|
void InstanceImportTask::processZipPack()
|
||||||
{
|
{
|
||||||
setStatus(tr("Extracting modpack"));
|
setStatus(tr("Extracting modpack"));
|
||||||
@ -246,9 +253,7 @@ void InstanceImportTask::extractFinished()
|
|||||||
|
|
||||||
void InstanceImportTask::extractAborted()
|
void InstanceImportTask::extractAborted()
|
||||||
{
|
{
|
||||||
emitFailed(tr("Instance import has been aborted."));
|
emitAborted();
|
||||||
emit aborted();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceImportTask::processFlame()
|
void InstanceImportTask::processFlame()
|
||||||
|
@ -80,6 +80,7 @@ private slots:
|
|||||||
void downloadSucceeded();
|
void downloadSucceeded();
|
||||||
void downloadFailed(QString reason);
|
void downloadFailed(QString reason);
|
||||||
void downloadProgressChanged(qint64 current, qint64 total);
|
void downloadProgressChanged(qint64 current, qint64 total);
|
||||||
|
void downloadAborted();
|
||||||
void extractFinished();
|
void extractFinished();
|
||||||
void extractAborted();
|
void extractAborted();
|
||||||
|
|
||||||
|
@ -784,6 +784,7 @@ class InstanceStaging : public Task {
|
|||||||
m_child.reset(child);
|
m_child.reset(child);
|
||||||
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceded);
|
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceded);
|
||||||
connect(child, &Task::failed, this, &InstanceStaging::childFailed);
|
connect(child, &Task::failed, this, &InstanceStaging::childFailed);
|
||||||
|
connect(child, &Task::aborted, this, &InstanceStaging::childAborted);
|
||||||
connect(child, &Task::status, this, &InstanceStaging::setStatus);
|
connect(child, &Task::status, this, &InstanceStaging::setStatus);
|
||||||
connect(child, &Task::progress, this, &InstanceStaging::setProgress);
|
connect(child, &Task::progress, this, &InstanceStaging::setProgress);
|
||||||
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceded);
|
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceded);
|
||||||
@ -794,17 +795,14 @@ class InstanceStaging : public Task {
|
|||||||
// FIXME/TODO: add ability to abort during instance commit retries
|
// FIXME/TODO: add ability to abort during instance commit retries
|
||||||
bool abort() override
|
bool abort() override
|
||||||
{
|
{
|
||||||
if (m_child && m_child->canAbort()) {
|
if (m_child && m_child->canAbort())
|
||||||
return m_child->abort();
|
return m_child->abort();
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool canAbort() const override
|
bool canAbort() const override
|
||||||
{
|
{
|
||||||
if (m_child && m_child->canAbort()) {
|
return (m_child && m_child->canAbort());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -834,6 +832,11 @@ class InstanceStaging : public Task {
|
|||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void childAborted()
|
||||||
|
{
|
||||||
|
emitAborted();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InstanceList * m_parent;
|
InstanceList * m_parent;
|
||||||
/*
|
/*
|
||||||
|
@ -90,6 +90,7 @@ void PackInstallTask::executeTask()
|
|||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
||||||
|
QObject::connect(netJob, &NetJob::aborted, this, &PackInstallTask::onDownloadAborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::onDownloadSucceeded()
|
void PackInstallTask::onDownloadSucceeded()
|
||||||
@ -169,6 +170,12 @@ void PackInstallTask::onDownloadFailed(QString reason)
|
|||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackInstallTask::onDownloadAborted()
|
||||||
|
{
|
||||||
|
jobPtr.reset();
|
||||||
|
emitAborted();
|
||||||
|
}
|
||||||
|
|
||||||
void PackInstallTask::deleteExistingFiles()
|
void PackInstallTask::deleteExistingFiles()
|
||||||
{
|
{
|
||||||
setStatus(tr("Deleting existing files..."));
|
setStatus(tr("Deleting existing files..."));
|
||||||
@ -675,6 +682,11 @@ void PackInstallTask::installConfigs()
|
|||||||
abortable = true;
|
abortable = true;
|
||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
connect(jobPtr.get(), &NetJob::aborted, [&]{
|
||||||
|
abortable = false;
|
||||||
|
jobPtr.reset();
|
||||||
|
emitAborted();
|
||||||
|
});
|
||||||
|
|
||||||
jobPtr->start();
|
jobPtr->start();
|
||||||
}
|
}
|
||||||
@ -831,6 +843,12 @@ void PackInstallTask::downloadMods()
|
|||||||
abortable = true;
|
abortable = true;
|
||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
connect(jobPtr.get(), &NetJob::aborted, [&]
|
||||||
|
{
|
||||||
|
abortable = false;
|
||||||
|
jobPtr.reset();
|
||||||
|
emitAborted();
|
||||||
|
});
|
||||||
|
|
||||||
jobPtr->start();
|
jobPtr->start();
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void onDownloadSucceeded();
|
void onDownloadSucceeded();
|
||||||
void onDownloadFailed(QString reason);
|
void onDownloadFailed(QString reason);
|
||||||
|
void onDownloadAborted();
|
||||||
|
|
||||||
void onModsDownloaded();
|
void onModsDownloaded();
|
||||||
void onModsExtracted();
|
void onModsExtracted();
|
||||||
|
@ -59,6 +59,7 @@ void PackFetchTask::fetch()
|
|||||||
|
|
||||||
QObject::connect(jobPtr.get(), &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
|
QObject::connect(jobPtr.get(), &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
|
||||||
QObject::connect(jobPtr.get(), &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
|
QObject::connect(jobPtr.get(), &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
|
||||||
|
QObject::connect(jobPtr.get(), &NetJob::aborted, this, &PackFetchTask::fileDownloadAborted);
|
||||||
|
|
||||||
jobPtr->start();
|
jobPtr->start();
|
||||||
}
|
}
|
||||||
@ -98,6 +99,14 @@ void PackFetchTask::fetchPrivate(const QStringList & toFetch)
|
|||||||
delete data;
|
delete data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QObject::connect(job, &NetJob::aborted, this, [this, job, data]{
|
||||||
|
emit aborted();
|
||||||
|
job->deleteLater();
|
||||||
|
|
||||||
|
data->clear();
|
||||||
|
delete data;
|
||||||
|
});
|
||||||
|
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,4 +213,9 @@ void PackFetchTask::fileDownloadFailed(QString reason)
|
|||||||
emit failed(reason);
|
emit failed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackFetchTask::fileDownloadAborted()
|
||||||
|
{
|
||||||
|
emit aborted();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,12 @@ private:
|
|||||||
protected slots:
|
protected slots:
|
||||||
void fileDownloadFinished();
|
void fileDownloadFinished();
|
||||||
void fileDownloadFailed(QString reason);
|
void fileDownloadFailed(QString reason);
|
||||||
|
void fileDownloadAborted();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished(ModpackList publicPacks, ModpackList thirdPartyPacks);
|
void finished(ModpackList publicPacks, ModpackList thirdPartyPacks);
|
||||||
void failed(QString reason);
|
void failed(QString reason);
|
||||||
|
void aborted();
|
||||||
|
|
||||||
void privateFileDownloadFinished(Modpack modpack);
|
void privateFileDownloadFinished(Modpack modpack);
|
||||||
void privateFileDownloadFailed(QString reason, QString packCode);
|
void privateFileDownloadFailed(QString reason, QString packCode);
|
||||||
|
@ -86,6 +86,7 @@ void PackInstallTask::downloadPack()
|
|||||||
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
||||||
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
||||||
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
|
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
|
||||||
|
connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::onDownloadAborted);
|
||||||
netJobContainer->start();
|
netJobContainer->start();
|
||||||
|
|
||||||
progress(1, 4);
|
progress(1, 4);
|
||||||
@ -110,6 +111,11 @@ void PackInstallTask::onDownloadProgress(qint64 current, qint64 total)
|
|||||||
setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10));
|
setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackInstallTask::onDownloadAborted()
|
||||||
|
{
|
||||||
|
emitAborted();
|
||||||
|
}
|
||||||
|
|
||||||
void PackInstallTask::unzip()
|
void PackInstallTask::unzip()
|
||||||
{
|
{
|
||||||
progress(2, 4);
|
progress(2, 4);
|
||||||
|
@ -38,6 +38,7 @@ private slots:
|
|||||||
void onDownloadSucceeded();
|
void onDownloadSucceeded();
|
||||||
void onDownloadFailed(QString reason);
|
void onDownloadFailed(QString reason);
|
||||||
void onDownloadProgress(qint64 current, qint64 total);
|
void onDownloadProgress(qint64 current, qint64 total);
|
||||||
|
void onDownloadAborted();
|
||||||
|
|
||||||
void onUnzipFinished();
|
void onUnzipFinished();
|
||||||
void onUnzipCanceled();
|
void onUnzipCanceled();
|
||||||
|
@ -65,9 +65,8 @@ bool PackInstallTask::abort()
|
|||||||
if (m_mod_id_resolver_task)
|
if (m_mod_id_resolver_task)
|
||||||
aborted &= m_mod_id_resolver_task->abort();
|
aborted &= m_mod_id_resolver_task->abort();
|
||||||
|
|
||||||
// FIXME: This should be 'emitAborted()', but InstanceStaging doesn't connect to the abort signal yet...
|
|
||||||
if (aborted)
|
if (aborted)
|
||||||
emitFailed(tr("Aborted"));
|
emitAborted();
|
||||||
|
|
||||||
return aborted;
|
return aborted;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ void Technic::SolderPackInstallTask::executeTask()
|
|||||||
auto job = m_filesNetJob.get();
|
auto job = m_filesNetJob.get();
|
||||||
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
|
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
|
||||||
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
||||||
|
connect(job, &NetJob::aborted, this, &Technic::SolderPackInstallTask::downloadAborted);
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +128,7 @@ void Technic::SolderPackInstallTask::fileListSucceeded()
|
|||||||
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded);
|
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded);
|
||||||
connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged);
|
connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged);
|
||||||
connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
|
||||||
|
connect(m_filesNetJob.get(), &NetJob::aborted, this, &Technic::SolderPackInstallTask::downloadAborted);
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +173,12 @@ void Technic::SolderPackInstallTask::downloadProgressChanged(qint64 current, qin
|
|||||||
setProgress(current / 2, total);
|
setProgress(current / 2, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Technic::SolderPackInstallTask::downloadAborted()
|
||||||
|
{
|
||||||
|
emitAborted();
|
||||||
|
m_filesNetJob.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void Technic::SolderPackInstallTask::extractFinished()
|
void Technic::SolderPackInstallTask::extractFinished()
|
||||||
{
|
{
|
||||||
if (!m_extractFuture.result())
|
if (!m_extractFuture.result())
|
||||||
|
@ -61,6 +61,7 @@ namespace Technic
|
|||||||
void downloadSucceeded();
|
void downloadSucceeded();
|
||||||
void downloadFailed(QString reason);
|
void downloadFailed(QString reason);
|
||||||
void downloadProgressChanged(qint64 current, qint64 total);
|
void downloadProgressChanged(qint64 current, qint64 total);
|
||||||
|
void downloadAborted();
|
||||||
void extractFinished();
|
void extractFinished();
|
||||||
void extractAborted();
|
void extractAborted();
|
||||||
|
|
||||||
|
@ -1656,6 +1656,10 @@ void MainWindow::runModalTask(Task *task)
|
|||||||
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
connect(task, &Task::aborted, [this]
|
||||||
|
{
|
||||||
|
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
|
||||||
|
});
|
||||||
ProgressDialog loadDialog(this);
|
ProgressDialog loadDialog(this);
|
||||||
loadDialog.setSkipButton(true, tr("Abort"));
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
loadDialog.execWithTask(task);
|
loadDialog.execWithTask(task);
|
||||||
|
@ -43,8 +43,7 @@ void ProgressDialog::setSkipButton(bool present, QString label)
|
|||||||
void ProgressDialog::on_skipButton_clicked(bool checked)
|
void ProgressDialog::on_skipButton_clicked(bool checked)
|
||||||
{
|
{
|
||||||
Q_UNUSED(checked);
|
Q_UNUSED(checked);
|
||||||
if (task->abort())
|
task->abort();
|
||||||
QDialog::reject();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressDialog::~ProgressDialog()
|
ProgressDialog::~ProgressDialog()
|
||||||
@ -81,7 +80,7 @@ int ProgressDialog::execWithTask(Task* task)
|
|||||||
connect(task, &Task::stepStatus, this, &ProgressDialog::changeStatus);
|
connect(task, &Task::stepStatus, this, &ProgressDialog::changeStatus);
|
||||||
connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
|
connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
|
||||||
|
|
||||||
connect(task, &Task::aborted, [this] { onTaskFailed(tr("Aborted by user")); });
|
connect(task, &Task::aborted, [this] { QDialog::reject(); });
|
||||||
|
|
||||||
m_is_multi_step = task->isMultiStep();
|
m_is_multi_step = task->isMultiStep();
|
||||||
if (!m_is_multi_step) {
|
if (!m_is_multi_step) {
|
||||||
|
@ -146,6 +146,7 @@ void Page::openedImpl()
|
|||||||
{
|
{
|
||||||
connect(ftbFetchTask.get(), &PackFetchTask::finished, this, &Page::ftbPackDataDownloadSuccessfully);
|
connect(ftbFetchTask.get(), &PackFetchTask::finished, this, &Page::ftbPackDataDownloadSuccessfully);
|
||||||
connect(ftbFetchTask.get(), &PackFetchTask::failed, this, &Page::ftbPackDataDownloadFailed);
|
connect(ftbFetchTask.get(), &PackFetchTask::failed, this, &Page::ftbPackDataDownloadFailed);
|
||||||
|
connect(ftbFetchTask.get(), &PackFetchTask::aborted, this, &Page::ftbPackDataDownloadAborted);
|
||||||
|
|
||||||
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFinished, this, &Page::ftbPrivatePackDataDownloadSuccessfully);
|
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFinished, this, &Page::ftbPrivatePackDataDownloadSuccessfully);
|
||||||
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFailed, this, &Page::ftbPrivatePackDataDownloadFailed);
|
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFailed, this, &Page::ftbPrivatePackDataDownloadFailed);
|
||||||
@ -220,7 +221,12 @@ void Page::ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList
|
|||||||
|
|
||||||
void Page::ftbPackDataDownloadFailed(QString reason)
|
void Page::ftbPackDataDownloadFailed(QString reason)
|
||||||
{
|
{
|
||||||
//TODO: Display the error
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Page::ftbPackDataDownloadAborted()
|
||||||
|
{
|
||||||
|
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
|
void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
|
||||||
|
@ -95,6 +95,7 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks);
|
void ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks);
|
||||||
void ftbPackDataDownloadFailed(QString reason);
|
void ftbPackDataDownloadFailed(QString reason);
|
||||||
|
void ftbPackDataDownloadAborted();
|
||||||
|
|
||||||
void ftbPrivatePackDataDownloadSuccessfully(Modpack pack);
|
void ftbPrivatePackDataDownloadSuccessfully(Modpack pack);
|
||||||
void ftbPrivatePackDataDownloadFailed(QString reason, QString packCode);
|
void ftbPrivatePackDataDownloadFailed(QString reason, QString packCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user