diff options
| author | 2018-08-16 10:28:03 -0400 | |
|---|---|---|
| committer | 2018-08-16 10:28:06 -0400 | |
| commit | aac807fd3a79432480f46520f228dd38ac97b54d (patch) | |
| tree | d61ec09673910fc7c86cd328229d315ad75f3f59 /src | |
| parent | Merge pull request #1005 from DarkLordZach/registered-fmt (diff) | |
| download | yuzu-aac807fd3a79432480f46520f228dd38ac97b54d.tar.gz yuzu-aac807fd3a79432480f46520f228dd38ac97b54d.tar.xz yuzu-aac807fd3a79432480f46520f228dd38ac97b54d.zip | |
qt/main: Get rid of compilation warnings
Gets rid of truncation warnings about conversion to int. While we're at
it, we can also de-hardcode the buffer size being used.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/main.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f7eee7769..2e62135f4 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -634,18 +634,22 @@ void GMainWindow::OnMenuInstallToNAND() { | |||
| 634 | if (!dest->Resize(src->GetSize())) | 634 | if (!dest->Resize(src->GetSize())) |
| 635 | return false; | 635 | return false; |
| 636 | 636 | ||
| 637 | std::array<u8, 0x1000> buffer{}; | ||
| 638 | const int progress_maximum = static_cast<int>(src->GetSize() / buffer.size()); | ||
| 639 | |||
| 637 | QProgressDialog progress(fmt::format("Installing file \"{}\"...", src->GetName()).c_str(), | 640 | QProgressDialog progress(fmt::format("Installing file \"{}\"...", src->GetName()).c_str(), |
| 638 | "Cancel", 0, src->GetSize() / 0x1000, this); | 641 | "Cancel", 0, progress_maximum, this); |
| 639 | progress.setWindowModality(Qt::WindowModal); | 642 | progress.setWindowModality(Qt::WindowModal); |
| 640 | 643 | ||
| 641 | std::array<u8, 0x1000> buffer{}; | 644 | for (size_t i = 0; i < src->GetSize(); i += buffer.size()) { |
| 642 | for (size_t i = 0; i < src->GetSize(); i += 0x1000) { | ||
| 643 | if (progress.wasCanceled()) { | 645 | if (progress.wasCanceled()) { |
| 644 | dest->Resize(0); | 646 | dest->Resize(0); |
| 645 | return false; | 647 | return false; |
| 646 | } | 648 | } |
| 647 | 649 | ||
| 648 | progress.setValue(i / 0x1000); | 650 | const int progress_value = static_cast<int>(i / buffer.size()); |
| 651 | progress.setValue(progress_value); | ||
| 652 | |||
| 649 | const auto read = src->Read(buffer.data(), buffer.size(), i); | 653 | const auto read = src->Read(buffer.data(), buffer.size(), i); |
| 650 | dest->Write(buffer.data(), read, i); | 654 | dest->Write(buffer.data(), read, i); |
| 651 | } | 655 | } |