Merge pull request #6831 from spycrab/qt_memcard_fixes

Qt/GCMemcardManager: Fix multiple issues
This commit is contained in:
spycrab 2018-05-13 23:14:46 +02:00 committed by GitHub
commit c7a0b6c9f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 9 deletions

View file

@ -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);
}
}

View file

@ -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 (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()
@ -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();