summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-rw-r--r--options/tie.cpp29
-rw-r--r--options/value.hpp22
2 files changed, 23 insertions, 28 deletions
diff --git a/options/tie.cpp b/options/tie.cpp
index 337843b1..493ff551 100644
--- a/options/tie.cpp
+++ b/options/tie.cpp
@@ -125,19 +125,30 @@ void tie_setting(value<slider_value>& v, QSlider* w)
value_::connect(w, &QSlider::valueChanged, &v, [=, &v](int pos)
{
- int q_min = w->minimum();
- int q_max = w->maximum();
- v = v->update_from_slider(pos, q_min, q_max);
+ run_in_thread_sync(w, [&]()
+ {
+ const int q_min = w->minimum();
+ const int q_max = w->maximum();
+ v = v().update_from_slider(pos, q_min, q_max);
+ w->setValue(v().to_slider_pos(q_min, q_max));
+ });
},
v.DIRECT_CONNTYPE);
- value_::connect(&v, value_::value_changed<slider_value>(), w, [=, &v](double) {
- const int q_min = w->minimum();
- const int q_max = w->maximum();
- const int pos = v->to_slider_pos(q_min, q_max);
- w->setValue(pos);
+ value_::connect(&v,
+ value_::value_changed<slider_value>(),
+ w,
+ [=, &v](double) {
+ run_in_thread_sync(w, [=, &v]()
+ {
+ const int q_min = w->minimum();
+ const int q_max = w->maximum();
+ const int pos = v->to_slider_pos(q_min, q_max);
+ v = v->update_from_slider(pos, q_min, q_max);
+ w->setValue(pos);
+ });
},
- v.SAFE_CONNTYPE);
+ v.DIRECT_CONNTYPE);
}
} // ns options
diff --git a/options/value.hpp b/options/value.hpp
index 849611d3..10903b19 100644
--- a/options/value.hpp
+++ b/options/value.hpp
@@ -39,9 +39,7 @@ template<typename t>
class value final : public value_
{
static_assert(std::is_same_v<t, remove_cvref_t<t>>);
- mutable QMutex mtx;
const t def;
- mutable t cached_value = def;
using traits = detail::value_traits<t>;
never_inline
@@ -97,24 +95,10 @@ public:
never_inline
void notify() const override
{
- if (is_null())
- return;
-
- auto x = get();
-
- bool b = progn(
- QMutexLocker l(&mtx);
- if (!traits::is_equal(x, cached_value))
- {
- cached_value = x;
- return true;
- }
- return false;
- );
-
- if (b) {
+ if (!is_null())
+ {
maybe_trace(true);
- emit valueChanged(traits::storage_from_value(x));
+ emit valueChanged(traits::storage_from_value(get()));
maybe_trace(false);
}
}