Qt/MemoryCardEditor: Handle switching to empty path at combobox index 0

This commit is contained in:
Albert Liu 2021-03-04 17:51:17 -08:00
parent 0218006e1b
commit e939507f42
1 changed files with 9 additions and 6 deletions

View File

@ -112,12 +112,7 @@ void MemoryCardEditorDialog::populateComboBox(QComboBox* cb)
void MemoryCardEditorDialog::loadCardFromComboBox(Card* card, int index)
{
QString filename = card->path_cb->itemData(index).toString();
if (filename.isEmpty())
return;
loadCard(filename, card);
loadCard(card->path_cb->itemData(index).toString(), card);
}
void MemoryCardEditorDialog::onCardASelectionChanged()
@ -166,6 +161,12 @@ bool MemoryCardEditorDialog::loadCard(const QString& filename, Card* card)
card->filename.clear();
if (filename.isEmpty())
{
updateButtonState();
return false;
}
std::string filename_str = filename.toStdString();
if (!MemoryCardImage::LoadFromFile(&card->data, filename_str.c_str()))
{
@ -435,4 +436,6 @@ void MemoryCardEditorDialog::updateButtonState()
m_ui.moveRight->setEnabled(both_cards_present && has_selection && !is_card_b);
m_ui.importCardA->setEnabled(card_a_present);
m_ui.importCardB->setEnabled(card_b_present);
m_ui.importFileToCardA->setEnabled(card_a_present);
m_ui.importFileToCardB->setEnabled(card_b_present);
}