]> sigrok.org Git - pulseview.git/commitdiff
Device: Make capability listing more robust
authorSoeren Apel <redacted>
Mon, 5 Jun 2017 12:09:38 +0000 (14:09 +0200)
committerUwe Hermann <redacted>
Mon, 5 Jun 2017 15:17:46 +0000 (17:17 +0200)
pv/binding/device.cpp

index 401644fd0672fa616c5c21586f619590e8b1cff1..458a9d69a71d64c2bda65cb24f3ad0b85e24394e 100644 (file)
@@ -147,20 +147,26 @@ void Device::bind_enum(const QString &name, const QString &desc,
        Property::Getter getter,
        Property::Setter setter, function<QString (Glib::VariantBase)> printer)
 {
-       Glib::VariantBase gvar;
-       vector< pair<Glib::VariantBase, QString> > 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<Glib::VariantBase, QString> > values;
+               while ((iter.next_value(gvar)))
+                       values.push_back(make_pair(gvar, printer(gvar)));
+
+               properties_.push_back(shared_ptr<Property>(new Enum(name, desc, values,
+                       getter, setter)));
 
-       properties_.push_back(shared_ptr<Property>(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,