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 "Core/FreeLookConfig.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include "Core/AchievementManager.h"
|
#include "Core/AchievementManager.h"
|
||||||
#include "Core/CPUThreadConfigCallback.h"
|
#include "Core/CPUThreadConfigCallback.h"
|
||||||
#include "Core/Config/AchievementSettings.h"
|
#include "Core/Config/AchievementSettings.h"
|
||||||
|
@ -14,7 +16,8 @@ namespace FreeLook
|
||||||
{
|
{
|
||||||
static Config s_config;
|
static Config s_config;
|
||||||
static Config s_active_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()
|
Config& GetConfig()
|
||||||
{
|
{
|
||||||
|
@ -39,14 +42,23 @@ Config::Config()
|
||||||
|
|
||||||
void Config::Refresh()
|
void Config::Refresh()
|
||||||
{
|
{
|
||||||
if (!s_has_registered_callback)
|
if (!s_config_changed_callback_id.has_value())
|
||||||
{
|
{
|
||||||
CPUThreadConfigCallback::AddConfigChangedCallback([] { s_config.Refresh(); });
|
s_config_changed_callback_id =
|
||||||
s_has_registered_callback = true;
|
CPUThreadConfigCallback::AddConfigChangedCallback([] { s_config.Refresh(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
camera_config.control_type = ::Config::Get(::Config::FL1_CONTROL_TYPE);
|
camera_config.control_type = ::Config::Get(::Config::FL1_CONTROL_TYPE);
|
||||||
enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED) &&
|
enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED) &&
|
||||||
!AchievementManager::GetInstance().IsHardcoreModeActive();
|
!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
|
} // namespace FreeLook
|
||||||
|
|
|
@ -27,6 +27,7 @@ struct Config final
|
||||||
{
|
{
|
||||||
Config();
|
Config();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
void Shutdown();
|
||||||
|
|
||||||
CameraConfig camera_config;
|
CameraConfig camera_config;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
|
@ -325,8 +325,9 @@ InputConfig* GetInputConfig()
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
s_config.UnregisterHotplugCallback();
|
s_config.UnregisterHotplugCallback();
|
||||||
|
|
||||||
s_config.ClearControllers();
|
s_config.ClearControllers();
|
||||||
|
|
||||||
|
GetConfig().Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize()
|
void Initialize()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue