summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Brière <fbriere@fbriere.net>2019-07-03 01:18:13 -0400
committerFrédéric Brière <fbriere@fbriere.net>2019-07-03 01:18:13 -0400
commitcdc748e253432ae505dda64ad6f4038554301483 (patch)
tree00d07163e0c8bed960178581670f92a813ccb3df
parent05082ae12051821b1d969e6672d9e4e5afe1bc07 (diff)
downloadtwinkle-cdc748e253432ae505dda64ad6f4038554301483.tar
twinkle-cdc748e253432ae505dda64ad6f4038554301483.tar.gz
twinkle-cdc748e253432ae505dda64ad6f4038554301483.tar.lz
twinkle-cdc748e253432ae505dda64ad6f4038554301483.tar.xz
twinkle-cdc748e253432ae505dda64ad6f4038554301483.zip
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<bool> for that purpose.) See https://stackoverflow.com/a/35226186 for more details about this subject.
-rw-r--r--src/sys_settings.cpp4
1 files changed, 2 insertions, 2 deletions
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;
}