From: Soeren Apel Date: Mon, 5 Jun 2017 12:09:38 +0000 (+0200) Subject: Device: Make capability listing more robust X-Git-Tag: pulseview-0.4.0~36 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a9627352f283dd4f83906dc1710a1d9d327fbe57;p=pulseview.git Device: Make capability listing more robust --- diff --git a/pv/binding/device.cpp b/pv/binding/device.cpp index 401644fd..458a9d69 100644 --- a/pv/binding/device.cpp +++ b/pv/binding/device.cpp @@ -147,20 +147,26 @@ void Device::bind_enum(const QString &name, const QString &desc, Property::Getter getter, Property::Setter setter, function printer) { - Glib::VariantBase gvar; - vector< pair > values; - assert(configurable_); if (!capabilities.count(Capability::LIST)) return; - Glib::VariantIter iter(configurable_->config_list(key)); - while ((iter.next_value(gvar))) - values.push_back(make_pair(gvar, printer(gvar))); + try { + Glib::VariantContainerBase gvar = configurable_->config_list(key); + Glib::VariantIter iter(gvar); + + vector< pair > values; + while ((iter.next_value(gvar))) + values.push_back(make_pair(gvar, printer(gvar))); + + properties_.push_back(shared_ptr(new Enum(name, desc, values, + getter, setter))); - properties_.push_back(shared_ptr(new Enum(name, desc, values, - getter, setter))); + } catch (sigrok::Error& e) { + qDebug() << "Error: Listing device key" << name << "failed!"; + return; + } } void Device::bind_int(const QString &name, const QString &desc, QString suffix,