From 8b3358e208bca9254b0c3e1b89f67c4c1f1c8c69 Mon Sep 17 00:00:00 2001 From: spycrab Date: Sat, 12 May 2018 20:35:16 +0200 Subject: [PATCH 1/3] Qt/GCMemcardManager: Fix broken export message --- Source/Core/DolphinQt2/GCMemcardManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt2/GCMemcardManager.cpp b/Source/Core/DolphinQt2/GCMemcardManager.cpp index e46f1a4412..14a84dfb29 100644 --- a/Source/Core/DolphinQt2/GCMemcardManager.cpp +++ b/Source/Core/DolphinQt2/GCMemcardManager.cpp @@ -300,7 +300,7 @@ void GCMemcardManager::ExportFiles(bool prompt) } QString text = count == 1 ? tr("Successfully exported the save file.") : - tr("Successfully exported the %1 save files."); + tr("Successfully exported the %1 save files.").arg(count); QMessageBox::information(this, tr("Success"), text); } From 229c92d0bfe6fede62902b3ed2389762ec46b448 Mon Sep 17 00:00:00 2001 From: spycrab Date: Sat, 12 May 2018 21:05:47 +0200 Subject: [PATCH 2/3] Qt/GCMemcardManager: Properly perform actions and do error checking --- Source/Core/DolphinQt2/GCMemcardManager.cpp | 28 +++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinQt2/GCMemcardManager.cpp b/Source/Core/DolphinQt2/GCMemcardManager.cpp index 14a84dfb29..2838ced163 100644 --- a/Source/Core/DolphinQt2/GCMemcardManager.cpp +++ b/Source/Core/DolphinQt2/GCMemcardManager.cpp @@ -321,7 +321,13 @@ void GCMemcardManager::ImportFile() if (path.isEmpty()) return; - m_slot_memcard[m_active_slot]->ImportGci(path.toStdString(), ""); + const auto result = m_slot_memcard[m_active_slot]->ImportGci(path.toStdString(), ""); + + if (result != SUCCESS) + { + QMessageBox::critical(this, tr("Import failed"), tr("Failed to import \"%1\".").arg(path)); + return; + } if (!m_slot_memcard[m_active_slot]->Save()) PanicAlertT("File write failed"); @@ -341,14 +347,19 @@ void GCMemcardManager::CopyFiles() auto sel = selection[i * m_slot_table[m_active_slot]->columnCount()]; int file_index = memcard->GetFileIndex(m_slot_table[m_active_slot]->row(sel)); - m_slot_memcard[!m_active_slot]->CopyFrom(*memcard, file_index); + const auto result = m_slot_memcard[!m_active_slot]->CopyFrom(*memcard, file_index); + + if (result != SUCCESS) + QMessageBox::warning(this, tr("Copy failed"), tr("Failed to copy file")); } - if (!m_slot_memcard[!m_active_slot]->Save()) - PanicAlertT("File write failed"); - for (int i = 0; i < SLOT_COUNT; i++) + { + if (!m_slot_memcard[i]->Save()) + PanicAlertT("File write failed"); + UpdateSlotTable(i); + } } void GCMemcardManager::DeleteFiles() @@ -374,13 +385,14 @@ void GCMemcardManager::DeleteFiles() { auto sel = selection[i * m_slot_table[m_active_slot]->columnCount()]; int file_index = memcard->GetFileIndex(m_slot_table[m_active_slot]->row(sel)); - memcard->RemoveFile(file_index); + if (memcard->RemoveFile(file_index) != SUCCESS) + QMessageBox::warning(this, tr("Remove failed"), tr("Failed to remove file")); } - QMessageBox::information(this, tr("Success"), tr("Successfully deleted files.")); - if (!memcard->Save()) PanicAlertT("File write failed"); + else + QMessageBox::information(this, tr("Success"), tr("Successfully deleted files.")); UpdateSlotTable(m_active_slot); UpdateActions(); From b094cda92944d1de3817fb0130a2b0247b9d308d Mon Sep 17 00:00:00 2001 From: spycrab Date: Sat, 12 May 2018 21:39:13 +0200 Subject: [PATCH 3/3] Core/GCMemcard: Fix checksums after modifying the memcard --- Source/Core/Core/HW/GCMemcard/GCMemcard.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index b0acaf00bb..26439a8811 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -727,6 +727,8 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector& saveBlo PreviousBat = &bat; } + FixChecksums(); + return SUCCESS; } @@ -792,6 +794,8 @@ u32 GCMemcard::RemoveFile(u8 index) // index in the directory array PreviousDir = &dir; } + FixChecksums(); + return SUCCESS; } @@ -817,6 +821,7 @@ u32 GCMemcard::CopyFrom(const GCMemcard& source, u8 index) case NOMEMCARD: return NOMEMCARD; default: + FixChecksums(); return ImportFile(tempDEntry, saveData); } }