Qt/GameCubePane: Fix inability to create new memory card file

This commit is contained in:
Techjar 2018-06-26 00:37:08 -04:00
parent beeb6754d2
commit 2491c53b92

View File

@ -167,11 +167,11 @@ void GameCubePane::OnConfigPressed(int slot)
return; return;
} }
QString filename = QString filename = QFileDialog::getSaveFileName(
QFileDialog::getOpenFileName(this, tr("Choose a file to open"), this, tr("Choose a file to open"), QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)), filter); filter, 0, QFileDialog::DontConfirmOverwrite);
if (filename.isEmpty() || !File::Exists(filename.toStdString())) if (filename.isEmpty())
return; return;
QString path_abs = QFileInfo(filename).absoluteFilePath(); QString path_abs = QFileInfo(filename).absoluteFilePath();
@ -179,16 +179,19 @@ void GameCubePane::OnConfigPressed(int slot)
// Memcard validity checks // Memcard validity checks
if (memcard) if (memcard)
{ {
GCMemcard mc(filename.toStdString()); if (File::Exists(filename.toStdString()))
if (!mc.IsValid())
{ {
QMessageBox::critical(this, tr("Error"), GCMemcard mc(filename.toStdString());
tr("Cannot use that file as a memory card.\n%1\n"
"is not a valid GameCube memory card file")
.arg(filename));
return; if (!mc.IsValid())
{
QMessageBox::critical(this, tr("Error"),
tr("Cannot use that file as a memory card.\n%1\n"
"is not a valid GameCube memory card file")
.arg(filename));
return;
}
} }
bool other_slot_memcard = bool other_slot_memcard =