mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 12:58:05 +03:00
FreeLook: Remove ConfigChangedCallback on shutdown
This commit is contained in:
parent
9db4067957
commit
d0dc8ae5e1
3 changed files with 19 additions and 5 deletions
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "Core/FreeLookConfig.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "Core/AchievementManager.h"
|
||||
#include "Core/CPUThreadConfigCallback.h"
|
||||
#include "Core/Config/AchievementSettings.h"
|
||||
|
@ -14,7 +16,8 @@ namespace FreeLook
|
|||
{
|
||||
static Config s_config;
|
||||
static Config s_active_config;
|
||||
static bool s_has_registered_callback = false;
|
||||
static std::optional<CPUThreadConfigCallback::ConfigChangedCallbackID>
|
||||
s_config_changed_callback_id = std::nullopt;
|
||||
|
||||
Config& GetConfig()
|
||||
{
|
||||
|
@ -39,14 +42,23 @@ Config::Config()
|
|||
|
||||
void Config::Refresh()
|
||||
{
|
||||
if (!s_has_registered_callback)
|
||||
if (!s_config_changed_callback_id.has_value())
|
||||
{
|
||||
s_config_changed_callback_id =
|
||||
CPUThreadConfigCallback::AddConfigChangedCallback([] { s_config.Refresh(); });
|
||||
s_has_registered_callback = true;
|
||||
}
|
||||
|
||||
camera_config.control_type = ::Config::Get(::Config::FL1_CONTROL_TYPE);
|
||||
enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED) &&
|
||||
!AchievementManager::GetInstance().IsHardcoreModeActive();
|
||||
}
|
||||
|
||||
void Config::Shutdown()
|
||||
{
|
||||
if (!s_config_changed_callback_id.has_value())
|
||||
return;
|
||||
|
||||
CPUThreadConfigCallback::RemoveConfigChangedCallback(*s_config_changed_callback_id);
|
||||
s_config_changed_callback_id.reset();
|
||||
}
|
||||
} // namespace FreeLook
|
||||
|
|
|
@ -27,6 +27,7 @@ struct Config final
|
|||
{
|
||||
Config();
|
||||
void Refresh();
|
||||
void Shutdown();
|
||||
|
||||
CameraConfig camera_config;
|
||||
bool enabled;
|
||||
|
|
|
@ -325,8 +325,9 @@ InputConfig* GetInputConfig()
|
|||
void Shutdown()
|
||||
{
|
||||
s_config.UnregisterHotplugCallback();
|
||||
|
||||
s_config.ClearControllers();
|
||||
|
||||
GetConfig().Shutdown();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue