From: Joel Holdsworth Date: Sat, 25 Jan 2014 12:06:25 +0000 (+0000) Subject: pv::prop::String: Do not create a widget if the initial value could not be retrieved X-Git-Tag: pulseview-0.2.0~109 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=c542721b53c7560e6b170a5596bf815571690fc4 pv::prop::String: Do not create a widget if the initial value could not be retrieved --- diff --git a/pv/prop/string.cpp b/pv/prop/string.cpp index 37efc148..7fcc6569 100644 --- a/pv/prop/string.cpp +++ b/pv/prop/string.cpp @@ -41,14 +41,14 @@ QWidget* String::get_widget(QWidget *parent, bool auto_commit) if (_line_edit) return _line_edit; - _line_edit = new QLineEdit(parent); - GVariant *const value = _getter ? _getter() : NULL; - if (value) { - _line_edit->setText(QString::fromUtf8( - g_variant_get_string(value, NULL))); - g_variant_unref(value); - } + if (!value) + return NULL; + + _line_edit = new QLineEdit(parent); + _line_edit->setText(QString::fromUtf8( + g_variant_get_string(value, NULL))); + g_variant_unref(value); if (auto_commit) connect(_line_edit, SIGNAL(textEdited(const QString&)),