fix: issues with aborts (again)
i hate it Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
f26be00571
commit
dfa220ef02
@ -9,9 +9,10 @@ Flame::FileResolvingTask::FileResolvingTask(const shared_qobject_ptr<QNetworkAcc
|
|||||||
|
|
||||||
bool Flame::FileResolvingTask::abort()
|
bool Flame::FileResolvingTask::abort()
|
||||||
{
|
{
|
||||||
|
bool aborted = true;
|
||||||
if (m_dljob)
|
if (m_dljob)
|
||||||
return m_dljob->abort();
|
aborted &= m_dljob->abort();
|
||||||
return true;
|
return aborted ? Task::abort() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flame::FileResolvingTask::executeTask()
|
void Flame::FileResolvingTask::executeTask()
|
||||||
|
@ -73,8 +73,8 @@ bool PackInstallTask::abort()
|
|||||||
|
|
||||||
void PackInstallTask::executeTask()
|
void PackInstallTask::executeTask()
|
||||||
{
|
{
|
||||||
setAbortable(true);
|
|
||||||
setStatus(tr("Getting the manifest..."));
|
setStatus(tr("Getting the manifest..."));
|
||||||
|
setAbortable(false);
|
||||||
|
|
||||||
// Find pack version
|
// Find pack version
|
||||||
auto version_it = std::find_if(m_pack.versions.constBegin(), m_pack.versions.constEnd(),
|
auto version_it = std::find_if(m_pack.versions.constBegin(), m_pack.versions.constEnd(),
|
||||||
@ -94,10 +94,12 @@ void PackInstallTask::executeTask()
|
|||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onManifestDownloadSucceeded);
|
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onManifestDownloadSucceeded);
|
||||||
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onManifestDownloadFailed);
|
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onManifestDownloadFailed);
|
||||||
|
QObject::connect(netJob, &NetJob::aborted, this, &PackInstallTask::abort);
|
||||||
QObject::connect(netJob, &NetJob::progress, this, &PackInstallTask::setProgress);
|
QObject::connect(netJob, &NetJob::progress, this, &PackInstallTask::setProgress);
|
||||||
|
|
||||||
m_net_job = netJob;
|
m_net_job = netJob;
|
||||||
|
|
||||||
|
setAbortable(true);
|
||||||
netJob->start();
|
netJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,8 +132,8 @@ void PackInstallTask::onManifestDownloadSucceeded()
|
|||||||
|
|
||||||
void PackInstallTask::resolveMods()
|
void PackInstallTask::resolveMods()
|
||||||
{
|
{
|
||||||
setAbortable(true);
|
|
||||||
setStatus(tr("Resolving mods..."));
|
setStatus(tr("Resolving mods..."));
|
||||||
|
setAbortable(false);
|
||||||
setProgress(0, 100);
|
setProgress(0, 100);
|
||||||
|
|
||||||
m_file_id_map.clear();
|
m_file_id_map.clear();
|
||||||
@ -164,8 +166,11 @@ void PackInstallTask::resolveMods()
|
|||||||
|
|
||||||
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::succeeded, this, &PackInstallTask::onResolveModsSucceeded);
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::succeeded, this, &PackInstallTask::onResolveModsSucceeded);
|
||||||
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onResolveModsFailed);
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onResolveModsFailed);
|
||||||
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::aborted, this, &PackInstallTask::abort);
|
||||||
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::progress, this, &PackInstallTask::setProgress);
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::progress, this, &PackInstallTask::setProgress);
|
||||||
|
|
||||||
|
setAbortable(true);
|
||||||
|
|
||||||
m_mod_id_resolver_task->start();
|
m_mod_id_resolver_task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,9 +284,8 @@ void PackInstallTask::onCreateInstanceSucceeded()
|
|||||||
|
|
||||||
void PackInstallTask::downloadPack()
|
void PackInstallTask::downloadPack()
|
||||||
{
|
{
|
||||||
setAbortable(true);
|
|
||||||
|
|
||||||
setStatus(tr("Downloading mods..."));
|
setStatus(tr("Downloading mods..."));
|
||||||
|
setAbortable(false);
|
||||||
|
|
||||||
auto* jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
|
auto* jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
|
||||||
for (auto const& file : m_version.files) {
|
for (auto const& file : m_version.files) {
|
||||||
@ -304,9 +308,12 @@ void PackInstallTask::downloadPack()
|
|||||||
|
|
||||||
connect(jobPtr, &NetJob::succeeded, this, &PackInstallTask::onModDownloadSucceeded);
|
connect(jobPtr, &NetJob::succeeded, this, &PackInstallTask::onModDownloadSucceeded);
|
||||||
connect(jobPtr, &NetJob::failed, this, &PackInstallTask::onModDownloadFailed);
|
connect(jobPtr, &NetJob::failed, this, &PackInstallTask::onModDownloadFailed);
|
||||||
|
connect(jobPtr, &NetJob::aborted, this, &PackInstallTask::abort);
|
||||||
connect(jobPtr, &NetJob::progress, this, &PackInstallTask::setProgress);
|
connect(jobPtr, &NetJob::progress, this, &PackInstallTask::setProgress);
|
||||||
|
|
||||||
m_net_job = jobPtr;
|
m_net_job = jobPtr;
|
||||||
|
|
||||||
|
setAbortable(true);
|
||||||
jobPtr->start();
|
jobPtr->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Pr
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
setAttribute(Qt::WidgetAttribute::WA_QuitOnClose, true);
|
||||||
setSkipButton(false);
|
setSkipButton(false);
|
||||||
changeProgress(0, 100);
|
changeProgress(0, 100);
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ int ProgressDialog::execWithTask(Task* task)
|
|||||||
return QDialog::DialogCode::Accepted;
|
return QDialog::DialogCode::Accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::DialogCode result;
|
QDialog::DialogCode result {};
|
||||||
if (handleImmediateResult(result)) {
|
if (handleImmediateResult(result)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -80,7 +81,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] { QDialog::reject(); });
|
connect(task, &Task::aborted, this, &ProgressDialog::hide);
|
||||||
connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
|
connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
|
||||||
|
|
||||||
m_is_multi_step = task->isMultiStep();
|
m_is_multi_step = task->isMultiStep();
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
void getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback);
|
void getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback);
|
||||||
|
|
||||||
[[nodiscard]] bool isMakingRequest() const { return jobPtr.get(); }
|
[[nodiscard]] bool isMakingRequest() const { return jobPtr.get(); }
|
||||||
|
[[nodiscard]] bool wasAborted() const { return m_aborted; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void requestFinished();
|
void requestFinished();
|
||||||
|
@ -105,7 +105,7 @@ void FtbPage::retranslate()
|
|||||||
|
|
||||||
void FtbPage::openedImpl()
|
void FtbPage::openedImpl()
|
||||||
{
|
{
|
||||||
if(!initialised)
|
if(!initialised || listModel->wasAborted())
|
||||||
{
|
{
|
||||||
listModel->request();
|
listModel->request();
|
||||||
initialised = true;
|
initialised = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user