2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

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.
This commit is contained in:
Lioncash 2018-08-16 10:28:03 -04:00
parent c594ec3417
commit aac807fd3a

View file

@ -634,18 +634,22 @@ void GMainWindow::OnMenuInstallToNAND() {
if (!dest->Resize(src->GetSize())) if (!dest->Resize(src->GetSize()))
return false; return false;
std::array<u8, 0x1000> buffer{};
const int progress_maximum = static_cast<int>(src->GetSize() / buffer.size());
QProgressDialog progress(fmt::format("Installing file \"{}\"...", src->GetName()).c_str(), QProgressDialog progress(fmt::format("Installing file \"{}\"...", src->GetName()).c_str(),
"Cancel", 0, src->GetSize() / 0x1000, this); "Cancel", 0, progress_maximum, this);
progress.setWindowModality(Qt::WindowModal); progress.setWindowModality(Qt::WindowModal);
std::array<u8, 0x1000> buffer{}; for (size_t i = 0; i < src->GetSize(); i += buffer.size()) {
for (size_t i = 0; i < src->GetSize(); i += 0x1000) {
if (progress.wasCanceled()) { if (progress.wasCanceled()) {
dest->Resize(0); dest->Resize(0);
return false; return false;
} }
progress.setValue(i / 0x1000); const int progress_value = static_cast<int>(i / buffer.size());
progress.setValue(progress_value);
const auto read = src->Read(buffer.data(), buffer.size(), i); const auto read = src->Read(buffer.data(), buffer.size(), i);
dest->Write(buffer.data(), read, i); dest->Write(buffer.data(), read, i);
} }