mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06: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:
@ -29,9 +29,9 @@ void AddLayer(std::unique_ptr<ConfigLayerLoader> loader);
|
|||||||
std::shared_ptr<Layer> GetLayer(LayerType layer);
|
std::shared_ptr<Layer> GetLayer(LayerType layer);
|
||||||
void RemoveLayer(LayerType layer);
|
void RemoveLayer(LayerType layer);
|
||||||
|
|
||||||
// Returns an ID that can be passed to RemoveConfigChangedCallback().
|
// Returns an ID that should be passed to RemoveConfigChangedCallback() when the callback is no
|
||||||
// The callback may be called from any thread.
|
// longer needed. The callback may be called from any thread.
|
||||||
ConfigChangedCallbackID AddConfigChangedCallback(ConfigChangedCallback func);
|
[[nodiscard]] ConfigChangedCallbackID AddConfigChangedCallback(ConfigChangedCallback func);
|
||||||
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id);
|
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id);
|
||||||
void OnConfigChanged();
|
void OnConfigChanged();
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@ struct ConfigChangedCallbackID
|
|||||||
bool operator==(const ConfigChangedCallbackID&) const = default;
|
bool operator==(const ConfigChangedCallbackID&) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
// returns an ID that can be passed to RemoveConfigChangedCallback()
|
// Returns an ID that should be passed to RemoveConfigChangedCallback() when the callback is no
|
||||||
ConfigChangedCallbackID AddConfigChangedCallback(Config::ConfigChangedCallback func);
|
// longer needed.
|
||||||
|
[[nodiscard]] ConfigChangedCallbackID AddConfigChangedCallback(Config::ConfigChangedCallback func);
|
||||||
|
|
||||||
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id);
|
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user