Qt: Fix WiiUpdate progress dialog cancel button

We didn't properly remove the default cancellation handler, which would
cause crashes if the dialog was gone too early.
This commit is contained in:
Léo Lam 2017-07-04 19:16:13 +02:00
parent ea3b351d92
commit 5ba6182bbc
1 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ static WiiUtils::UpdateResult ShowProgress(QWidget* parent, Callable function, A
auto* cancel_button = new QPushButton(QObject::tr("&Cancel"), parent); auto* cancel_button = new QPushButton(QObject::tr("&Cancel"), parent);
dialog.setCancelButton(cancel_button); dialog.setCancelButton(cancel_button);
Common::Flag was_cancelled; Common::Flag was_cancelled;
QObject::disconnect(&dialog, &QProgressDialog::canceled, &dialog, &QProgressDialog::cancel); QObject::disconnect(&dialog, &QProgressDialog::canceled, nullptr, nullptr);
QObject::connect(&dialog, &QProgressDialog::canceled, [&] { QObject::connect(&dialog, &QProgressDialog::canceled, [&] {
dialog.setLabelText(QObject::tr("Finishing the update...\nThis can take a while.")); dialog.setLabelText(QObject::tr("Finishing the update...\nThis can take a while."));
cancel_button->setEnabled(false); cancel_button->setEnabled(false);
@ -120,7 +120,7 @@ static WiiUtils::UpdateResult ShowProgress(QWidget* parent, Callable function, A
return !was_cancelled.IsSet(); return !was_cancelled.IsSet();
}, },
std::forward<Args>(args)...); std::forward<Args>(args)...);
QueueOnObject(&dialog, [&dialog] { dialog.close(); }); QueueOnObject(&dialog, [&dialog] { dialog.done(0); });
return res; return res;
}); });