MainWindow: Fix use-after-free during shutdown

Remove ConfigChangedCallback in MainWindow's destructor to prevent the
callback from accessing the destroyed MainWindow afterward.

After MainWindow is destroyed UICommon::Shutdown calls
LogManager::Shutdown which ultimately triggers any remaining callbacks.
This resulted in calling MainWindow::OnHardcoreChanged, which crashed in
debug builds and didn't have any obvious effect in release builds.
This commit is contained in:
Dentomologist 2025-04-24 11:36:18 -07:00
parent 805307f432
commit e37a195192
2 changed files with 8 additions and 1 deletions

View file

@ -11,6 +11,10 @@
#include <optional>
#include <string>
#ifdef USE_RETRO_ACHIEVEMENTS
#include "Common/Config/Config.h"
#endif // USE_RETRO_ACHIEVEMENTS
#include "Core/Boot/Boot.h"
class QMenu;
@ -261,6 +265,7 @@ private:
#ifdef USE_RETRO_ACHIEVEMENTS
AchievementsWindow* m_achievements_window = nullptr;
Config::ConfigChangedCallbackID m_config_changed_callback_id;
#endif // USE_RETRO_ACHIEVEMENTS
AssemblerWidget* m_assembler_widget;