Permalink
Browse files

Merge pull request #6831 from spycrab/qt_memcard_fixes

Qt/GCMemcardManager: Fix multiple issues
  • Loading branch information...
spycrab committed May 13, 2018
2 parents 2be8c35 + b094cda commit c7a0b6c9f829d94d7f3bdadca502f8e67f6caadb
Showing with 26 additions and 9 deletions.
  1. +5 −0 Source/Core/Core/HW/GCMemcard/GCMemcard.cpp
  2. +21 −9 Source/Core/DolphinQt2/GCMemcardManager.cpp
@@ -727,6 +727,8 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& 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);
}
}
@@ -301,7 +301,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);
}
@@ -322,7 +322,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");
@@ -342,14 +348,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 (!m_slot_memcard[!m_active_slot]->Save())
PanicAlertT("File write failed");
if (result != SUCCESS)
QMessageBox::warning(this, tr("Copy failed"), tr("Failed to copy file"));
}
for (int i = 0; i < SLOT_COUNT; i++)
{
if (!m_slot_memcard[i]->Save())
PanicAlertT("File write failed");
UpdateSlotTable(i);
}
}
void GCMemcardManager::DeleteFiles()
@@ -375,13 +386,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();

0 comments on commit c7a0b6c

Please sign in to comment.