From: Joel Holdsworth Date: Sat, 25 Jan 2014 12:05:38 +0000 (+0000) Subject: pv::prop::Bool: Do not create a widget if the initial value could not be retrieved X-Git-Tag: pulseview-0.2.0~111 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=33666ec04c2a8bdeecd39eebfcf853a3628d6501;p=pulseview.git pv::prop::Bool: Do not create a widget if the initial value could not be retrieved --- diff --git a/pv/prop/bool.cpp b/pv/prop/bool.cpp index ac142fd4..e0e052fc 100644 --- a/pv/prop/bool.cpp +++ b/pv/prop/bool.cpp @@ -42,15 +42,14 @@ QWidget* Bool::get_widget(QWidget *parent, bool auto_commit) if (_check_box) return _check_box; - _check_box = new QCheckBox(name(), parent); - GVariant *const value = _getter ? _getter() : NULL; + if (!value) + return NULL; - if (value) { - _check_box->setCheckState(g_variant_get_boolean(value) ? - Qt::Checked : Qt::Unchecked); - g_variant_unref(value); - } + _check_box = new QCheckBox(name(), parent); + _check_box->setCheckState(g_variant_get_boolean(value) ? + Qt::Checked : Qt::Unchecked); + g_variant_unref(value); if (auto_commit) connect(_check_box, SIGNAL(stateChanged(int)),