CheatsManager: Create ARCodeWidget and GeckoCodeWidget only once.

Create ARCodeWidget and GeckoCodeWidget once on startup rather than
every time a game is launched or shutdown.

In addition to losing focus on the tab (since the previous widget and
tab no longer existed), the behavior prior to this commit could cause a
crash if the user initiated a game shutdown and then opened a code edit
window since the AR/GeckoCodeWidget would get deleted in the meantime.
This commit is contained in:
Dentomologist
2024-07-30 19:55:27 -07:00
parent 232d24109d
commit f4db168a8e
6 changed files with 96 additions and 72 deletions

View File

@ -10,6 +10,7 @@
#include "Common/CommonTypes.h"
class CheatCodeEditor;
class CheatWarningWidget;
#ifdef USE_RETRO_ACHIEVEMENTS
class HardcoreWarningWidget;
@ -33,6 +34,8 @@ public:
bool restart_required = true);
~GeckoCodeWidget() override;
void ChangeGame(std::string game_id, std::string gametdb_id, u16 game_revision);
signals:
void OpenGeneralSettings();
#ifdef USE_RETRO_ACHIEVEMENTS
@ -75,6 +78,7 @@ private:
QPushButton* m_edit_code;
QPushButton* m_remove_code;
QPushButton* m_download_codes;
CheatCodeEditor* m_cheat_code_editor;
std::vector<Gecko::GeckoCode> m_gecko_codes;
bool m_restart_required;
};