Application: improve drawUnsafeWidget().

This commit is contained in:
Guillaume Jacquemin 2024-12-08 20:33:13 +01:00
parent 6aba2bf8c5
commit e425c81db6
Signed by: williamjcm
SSH key fingerprint: SHA256:AYLOg+iTV0ElElnlu4vqM4edFazVdRiuQB0Y5LoKc4A

View file

@ -186,6 +186,7 @@ class Application: public Platform::Sdl2Application, public efsw::FileWatchListe
template<typename Functor, typename... Args> template<typename Functor, typename... Args>
bool drawUnsafeWidget(Functor func, Args... args) { bool drawUnsafeWidget(Functor func, Args... args) {
static_assert(std::is_invocable_r_v<bool, Functor, Args...>);
GameState game_state = _gameState; // Copying the value to reduce the risk of a data race. GameState game_state = _gameState; // Copying the value to reduce the risk of a data race.
ImGui::BeginDisabled(game_state != GameState::NotRunning); ImGui::BeginDisabled(game_state != GameState::NotRunning);
bool result = func(std::forward<Args>(args)...); bool result = func(std::forward<Args>(args)...);