fix: make loadDialog close after failure in runModalTask
Signed-off-by: Lenny McLennington <lenny@sneed.church>
This commit is contained in:
parent
33634764e9
commit
b752875325
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 Lenny McLennington <lenny@sneed.church>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -1631,8 +1632,14 @@ InstanceView
|
||||
|
||||
void MainWindow::runModalTask(Task *task)
|
||||
{
|
||||
connect(task, &Task::failed, [this](QString reason)
|
||||
ProgressDialog loadDialog(this);
|
||||
|
||||
connect(task, &Task::failed, [this, &loadDialog](QString reason)
|
||||
{
|
||||
// FIXME:
|
||||
// HACK: I don't know why calling show() on this CustomMessageBox causes loadDialog to not close,
|
||||
// but this forces it to close BEFORE the CustomMessageBox gets opened... I think this is a bad fix
|
||||
loadDialog.close();
|
||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||
});
|
||||
connect(task, &Task::succeeded, [this, task]()
|
||||
@ -1643,13 +1650,15 @@ void MainWindow::runModalTask(Task *task)
|
||||
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||
}
|
||||
});
|
||||
connect(task, &Task::aborted, [this]
|
||||
connect(task, &Task::aborted, [this, &loadDialog]
|
||||
{
|
||||
// HACK: Same bad hack as above slot for Task::failed
|
||||
loadDialog.close();
|
||||
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
|
||||
});
|
||||
ProgressDialog loadDialog(this);
|
||||
loadDialog.setSkipButton(true, tr("Abort"));
|
||||
loadDialog.execWithTask(task);
|
||||
qDebug() << "MainWindow::runModalTask: execWithTask exited properly";
|
||||
}
|
||||
|
||||
void MainWindow::instanceFromInstanceTask(InstanceTask *rawTask)
|
||||
|
Loading…
Reference in New Issue
Block a user