From 515a3f8e3a3e6091cc58798c36fe51859178143b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 19 Oct 2021 09:18:57 +0200 Subject: Revert "options/tie: fix deadlocks" This reverts commit 2ef545b487209fb03bc2506b8e9bfa345d0f392b. --- options/tie.cpp | 29 ++++++++++++++++++++--------- options/value.hpp | 22 +++------------------- 2 files changed, 23 insertions(+), 28 deletions(-) (limited to 'options') 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& 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(), 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(), + 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 class value final : public value_ { static_assert(std::is_same_v>); - mutable QMutex mtx; const t def; - mutable t cached_value = def; using traits = detail::value_traits; 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); } } -- cgit v1.2.3