Merge pull request #9536 from Filoppi/config_fixes
Don't call OnConfigChanged() unless config actually changed
This commit is contained in:
commit
9d0983c9c9
|
@ -94,8 +94,8 @@ LayerType GetActiveLayerForConfig(const Info<T>& info)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Set(LayerType layer, const Info<T>& info, const std::common_type_t<T>& value)
|
void Set(LayerType layer, const Info<T>& info, const std::common_type_t<T>& value)
|
||||||
{
|
{
|
||||||
GetLayer(layer)->Set(info, value);
|
if (GetLayer(layer)->Set(info, value))
|
||||||
OnConfigChanged();
|
OnConfigChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -118,24 +118,25 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Set(const Info<T>& config_info, const std::common_type_t<T>& value)
|
bool Set(const Info<T>& config_info, const std::common_type_t<T>& value)
|
||||||
{
|
{
|
||||||
Set(config_info.GetLocation(), value);
|
return Set(config_info.GetLocation(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Set(const Location& location, const T& value)
|
bool Set(const Location& location, const T& value)
|
||||||
{
|
{
|
||||||
Set(location, ValueToString(value));
|
return Set(location, ValueToString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const Location& location, std::string new_value)
|
bool Set(const Location& location, std::string new_value)
|
||||||
{
|
{
|
||||||
const auto iter = m_map.find(location);
|
const auto iter = m_map.find(location);
|
||||||
if (iter != m_map.end() && iter->second == new_value)
|
if (iter != m_map.end() && iter->second == new_value)
|
||||||
return;
|
return false;
|
||||||
m_is_dirty = true;
|
m_is_dirty = true;
|
||||||
m_map.insert_or_assign(location, std::move(new_value));
|
m_map.insert_or_assign(location, std::move(new_value));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkAsDirty() { m_is_dirty = true; }
|
void MarkAsDirty() { m_is_dirty = true; }
|
||||||
|
|
|
@ -381,7 +381,9 @@ void Init()
|
||||||
Config::SetBase(Settings::SERVER_PORT, 0);
|
Config::SetBase(Settings::SERVER_PORT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It would be much better to unbind from this callback on DeInit but it's not possible as of now
|
||||||
Config::AddConfigChangedCallback(ConfigChanged);
|
Config::AddConfigChangedCallback(ConfigChanged);
|
||||||
|
ConfigChanged(); // Call it immediately to load settings
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopulateDevices()
|
void PopulateDevices()
|
||||||
|
|
Loading…
Reference in New Issue