diff --git a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp index c3ebe967d3..b45cfb3772 100644 --- a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp @@ -31,14 +31,17 @@ ARCodeWidget::ARCodeWidget(std::string game_id, u16 game_revision, bool restart_ CreateWidgets(); ConnectWidgets(); - IniFile game_ini_local; + if (!m_game_id.empty()) + { + IniFile game_ini_local; - // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI - // will always be stored in GS/${GAMEID}.ini - game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); + // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI + // will always be stored in GS/${GAMEID}.ini + game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); - m_ar_codes = ActionReplay::LoadCodes(game_ini_default, game_ini_local); + const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); + m_ar_codes = ActionReplay::LoadCodes(game_ini_default, game_ini_local); + } UpdateList(); OnSelectionChanged(); @@ -54,6 +57,11 @@ void ARCodeWidget::CreateWidgets() m_code_edit = new QPushButton(tr("&Edit Code...")); m_code_remove = new QPushButton(tr("&Remove Code")); + m_code_list->setEnabled(!m_game_id.empty()); + m_code_add->setEnabled(!m_game_id.empty()); + m_code_edit->setEnabled(!m_game_id.empty()); + m_code_remove->setEnabled(!m_game_id.empty()); + m_code_list->setContextMenuPolicy(Qt::CustomContextMenu); auto* button_layout = new QHBoxLayout; @@ -171,6 +179,9 @@ void ARCodeWidget::UpdateList() void ARCodeWidget::SaveCodes() { + if (m_game_id.empty()) + return; + const auto ini_path = std::string(File::GetUserPath(D_GAMESETTINGS_IDX)).append(m_game_id).append(".ini");