From cdc748e253432ae505dda64ad6f4038554301483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Wed, 3 Jul 2019 01:18:13 -0400 Subject: Use a mutex in all t_sys_settings getters/setters, even bool Despite what one might intuitively expect, the C++ standard does not make any guarantee about fundamental types being atomic, not even bool. (In fact, it explicitly mentions the existence of std::atomic for that purpose.) See https://stackoverflow.com/a/35226186 for more details about this subject. --- src/sys_settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sys_settings.cpp b/src/sys_settings.cpp index bb07539..b8af8fe 100644 --- a/src/sys_settings.cpp +++ b/src/sys_settings.cpp @@ -636,6 +636,7 @@ bool t_sys_settings::get_show_buddy_list(void) const { } bool t_sys_settings::get_gui_show_call_osd() const { + t_mutex_guard guard(mtx_sys); return gui_show_call_osd; } @@ -973,8 +974,7 @@ void t_sys_settings::set_warn_hide_user(bool b) { } void t_sys_settings::set_gui_show_call_osd(bool b) { - // Using mutexes in primitive type getters/setters doesn't make any sense. - // TODO: remove t_mutex_guard from other getters/setters like this one. + t_mutex_guard guard(mtx_sys); gui_show_call_osd = b; } -- cgit v1.2.3