diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-28 03:02:57 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-16 07:48:18 +0100 |
commit | 6f04e4ca46e6f2dcd3eda63529a1bbd915f7676b (patch) | |
tree | 9aeb1332980c4285396457ad9f278495064549b5 /options/scoped.cpp | |
parent | 3be3bb256f3e9362f8889f0532f875c5ad3b41fb (diff) |
clang-tidy fixes only
Maybe global `-Wcomma' is too harsh.
There should be no functional changes whatsoever.
Diffstat (limited to 'options/scoped.cpp')
-rw-r--r-- | options/scoped.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/options/scoped.cpp b/options/scoped.cpp index 8f1ef202..ef5b94d6 100644 --- a/options/scoped.cpp +++ b/options/scoped.cpp @@ -10,17 +10,17 @@ namespace options { // XXX hack: the flag shouldn't be here as action at distance -sh 20160926 -static std::atomic_bool teardown_flag(false); -static void set_teardown_flag(bool value); +static std::atomic<bool> teardown_flag{false}; +[[nodiscard]] static bool set_teardown_flag(bool value); static void ensure_thread(); static bool is_tracker_teardown(); -static void set_teardown_flag(bool value) +static bool set_teardown_flag(bool value) { // flag being set means "opts" is about to go out of scope due to tracker stop // in this case we don't reload options. we only want to reload when cancel is pressed. ensure_thread(); - teardown_flag = value; + return teardown_flag.exchange(value); } static void ensure_thread() @@ -59,14 +59,13 @@ opts::opts(const QString &name) : b(make_bundle(name)) { } -with_tracker_teardown::with_tracker_teardown() : old_value(teardown_flag) +with_tracker_teardown::with_tracker_teardown() : old_value{set_teardown_flag(true)} { - set_teardown_flag(true); } with_tracker_teardown::~with_tracker_teardown() { - set_teardown_flag(old_value); + (void)set_teardown_flag(old_value); } } // ns options |