mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 12:58:05 +03:00
Config: Add [[nodiscard]] to AddConfigChangedCallback
Require callers of Config::AddConfigChangedCallback and CPUThreadConfigCallback::AddConfigChangedCallback to handle the returned ConfigChangedCallbackIDs to hopefully prevent future issues with callbacks getting called after their associated objects have been destroyed.
This commit is contained in:
parent
45b9def42c
commit
3a883f28d6
2 changed files with 6 additions and 5 deletions
|
@ -29,9 +29,9 @@ void AddLayer(std::unique_ptr<ConfigLayerLoader> loader);
|
|||
std::shared_ptr<Layer> GetLayer(LayerType layer);
|
||||
void RemoveLayer(LayerType layer);
|
||||
|
||||
// Returns an ID that can be passed to RemoveConfigChangedCallback().
|
||||
// The callback may be called from any thread.
|
||||
ConfigChangedCallbackID AddConfigChangedCallback(ConfigChangedCallback func);
|
||||
// Returns an ID that should be passed to RemoveConfigChangedCallback() when the callback is no
|
||||
// longer needed. The callback may be called from any thread.
|
||||
[[nodiscard]] ConfigChangedCallbackID AddConfigChangedCallback(ConfigChangedCallback func);
|
||||
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id);
|
||||
void OnConfigChanged();
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@ struct ConfigChangedCallbackID
|
|||
bool operator==(const ConfigChangedCallbackID&) const = default;
|
||||
};
|
||||
|
||||
// returns an ID that can be passed to RemoveConfigChangedCallback()
|
||||
ConfigChangedCallbackID AddConfigChangedCallback(Config::ConfigChangedCallback func);
|
||||
// Returns an ID that should be passed to RemoveConfigChangedCallback() when the callback is no
|
||||
// longer needed.
|
||||
[[nodiscard]] ConfigChangedCallbackID AddConfigChangedCallback(Config::ConfigChangedCallback func);
|
||||
|
||||
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue