Merge pull request #8306 from JosJuice/volumeverifier-dialog

VolumeVerifier: Allocate QProgressDialog on stack
This commit is contained in:
Connor McLaughlin 2019-08-09 23:02:00 +10:00 committed by GitHub
commit 7c1ca1fda1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,18 +98,18 @@ void VerifyWidget::Verify()
// We have to divide the number of processed bytes with something so it won't make ints overflow // We have to divide the number of processed bytes with something so it won't make ints overflow
constexpr int DIVISOR = 0x100; constexpr int DIVISOR = 0x100;
QProgressDialog* progress = new QProgressDialog(tr("Verifying"), tr("Cancel"), 0, QProgressDialog progress(tr("Verifying"), tr("Cancel"), 0, verifier.GetTotalBytes() / DIVISOR,
verifier.GetTotalBytes() / DIVISOR, this); this);
progress->setWindowTitle(tr("Verifying")); progress.setWindowTitle(tr("Verifying"));
progress->setWindowFlags(progress->windowFlags() & ~Qt::WindowContextHelpButtonHint); progress.setWindowFlags(progress.windowFlags() & ~Qt::WindowContextHelpButtonHint);
progress->setMinimumDuration(500); progress.setMinimumDuration(500);
progress->setWindowModality(Qt::WindowModal); progress.setWindowModality(Qt::WindowModal);
verifier.Start(); verifier.Start();
while (verifier.GetBytesProcessed() != verifier.GetTotalBytes()) while (verifier.GetBytesProcessed() != verifier.GetTotalBytes())
{ {
progress->setValue(verifier.GetBytesProcessed() / DIVISOR); progress.setValue(verifier.GetBytesProcessed() / DIVISOR);
if (progress->wasCanceled()) if (progress.wasCanceled())
return; return;
verifier.Process(); verifier.Process();
@ -117,7 +117,7 @@ void VerifyWidget::Verify()
verifier.Finish(); verifier.Finish();
DiscIO::VolumeVerifier::Result result = verifier.GetResult(); DiscIO::VolumeVerifier::Result result = verifier.GetResult();
progress->reset(); progress.setValue(verifier.GetBytesProcessed() / DIVISOR);
m_summary_text->setText(QString::fromStdString(result.summary_text)); m_summary_text->setText(QString::fromStdString(result.summary_text));