X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fprop%2Fdouble.cpp;h=54540bc68ded41c0575c3202726ac383665b5814;hb=50f97924a2de49393de617a891190f053825454f;hp=188286ae1c4ff08a22687c0ac11704c69920ff23;hpb=b1fe148e0dce6e369c9d4770ca935a6a9ec94b59;p=pulseview.git diff --git a/pv/prop/double.cpp b/pv/prop/double.cpp index 188286ae..54540bc6 100644 --- a/pv/prop/double.cpp +++ b/pv/prop/double.cpp @@ -24,8 +24,8 @@ #include "double.h" -using namespace std; -using namespace boost; +using boost::optional; +using std::pair; namespace pv { namespace prop { @@ -55,6 +55,16 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit) if (_spin_box) return _spin_box; + if (!_getter) + return NULL; + + Glib::VariantBase variant = _getter(); + if (!variant.gobj()) + return NULL; + + double value = Glib::VariantBase::cast_dynamic>( + variant).get(); + _spin_box = new QDoubleSpinBox(parent); _spin_box->setDecimals(_decimals); _spin_box->setSuffix(_suffix); @@ -63,12 +73,7 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit) if (_step) _spin_box->setSingleStep(*_step); - GVariant *const value = _getter ? _getter() : NULL; - - if (value) { - _spin_box->setValue(g_variant_get_double(value)); - g_variant_unref(value); - } + _spin_box->setValue(value); if (auto_commit) connect(_spin_box, SIGNAL(valueChanged(double)), @@ -84,7 +89,7 @@ void Double::commit() if (!_spin_box) return; - _setter(g_variant_new_double(_spin_box->value())); + _setter(Glib::Variant::create(_spin_box->value())); } void Double::on_value_changed(double)