summaryrefslogtreecommitdiffhomepage
path: root/options/scoped.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'options/scoped.cpp')
-rw-r--r--options/scoped.cpp13
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