summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-29 05:39:47 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-29 05:41:35 +0100
commite766ee9b110c81e334d2e3305df563d9cff3e604 (patch)
tree4d52c32df85cd9a09e13620c4bd6514a380c109a
parent05ef8b437c026f78fb43010311dcc169e3112bb9 (diff)
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
-rw-r--r--options/tie.hpp25
1 files 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<int>& v, QTabWidget* t)
template<>
inline void tie_setting(value<slider_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<void(base_value::*)(double) const>(&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);
},