]> sigrok.org Git - pulseview.git/commitdiff
pv::prop::Bool: Do not create a widget if the initial value could not be retrieved
authorJoel Holdsworth <redacted>
Sat, 25 Jan 2014 12:05:38 +0000 (12:05 +0000)
committerBert Vermeulen <redacted>
Sat, 25 Jan 2014 14:34:00 +0000 (15:34 +0100)
pv/prop/bool.cpp

index ac142fd440403c6b015c441f6e6b1d13ae3923aa..e0e052fc6b2b377c3d580192beda10793d331884 100644 (file)
@@ -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)),