# HG changeset patch # User Patric Stout # Date 2021-06-17 16:58:59 # Node ID 60c9c8536270458b83d84ea0b5256ea49ccbcc47 # Parent feac296d221b2057c42353c6fb49831f41122e52 Fix: thread safety issue during exiting the game (#9380) _exit_game is read by the draw-thread to know when to exit, but most of the time written by the game-thread. diff --git a/src/gfx.cpp b/src/gfx.cpp --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -41,7 +41,7 @@ bool _right_button_down; ///< Is righ bool _right_button_clicked; ///< Is right mouse button clicked? DrawPixelInfo _screen; bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot) -bool _exit_game; +std::atomic _exit_game; GameMode _game_mode; SwitchMode _switch_mode; ///< The next mainloop command. PauseMode _pause_mode; diff --git a/src/openttd.h b/src/openttd.h --- a/src/openttd.h +++ b/src/openttd.h @@ -10,6 +10,7 @@ #ifndef OPENTTD_H #define OPENTTD_H +#include #include "core/enum_type.hpp" /** Mode which defines the state of the game. */ @@ -52,7 +53,7 @@ enum DisplayOptions { extern GameMode _game_mode; extern SwitchMode _switch_mode; -extern bool _exit_game; +extern std::atomic _exit_game; extern bool _save_config; /** Modes of pausing we've got */