From e766ee9b110c81e334d2e3305df563d9cff3e604 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Nov 2016 05:39:47 +0100 Subject: options/tie: fix for enum Fundamentally this was caused by incorrect lambda capture spec for the qobject ptr. We need to capture the pointer by value. Reported-by: @huliqan on IL-2 Sturmovik Russian forum. Fixes: hatire serial port params --- options/tie.hpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/options/tie.hpp b/options/tie.hpp index accd958e..bdd992d8 100644 --- a/options/tie.hpp +++ b/options/tie.hpp @@ -144,25 +144,34 @@ inline void tie_setting(value& v, QTabWidget* t) template<> inline void tie_setting(value& v, QSlider* w) { - // we can't get these at runtime since signals cross threads - const int q_min = w->minimum(); - const int q_max = w->maximum(); + { + const int q_min = w->minimum(); + const int q_max = w->maximum(); - w->setValue(v->to_slider_pos(q_min, q_max)); - v = v->update_from_slider(w->value(), q_min, q_max); + w->setValue(v->to_slider_pos(q_min, q_max)); + v = v->update_from_slider(w->value(), q_min, q_max); + } base_value::connect(w, &QSlider::valueChanged, &v, - [=, &v](int pos) { - v = v->update_from_slider(pos, q_min, q_max); - w->setValue(v->to_slider_pos(q_min, q_max)); + [=, &v](int pos) + { + 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); base_value::connect(&v, static_cast(&base_value::valueChanged), w, [=, &v](double) { + const int q_min = w->minimum(); + const int q_max = w->maximum(); w->setValue(v->to_slider_pos(q_min, q_max)); v = v->update_from_slider(w->value(), q_min, q_max); }, -- cgit v1.2.3