]> sigrok.org Git - pulseview.git/blobdiff - pv/prop/binding/deviceoptions.cpp
DeviceOptions: Added an error handler for the case when a device exposes an enum...
[pulseview.git] / pv / prop / binding / deviceoptions.cpp
index ea8f4b4218463e1c6e5ab03308ca6358d0066df2..2dc237a885ec6eec83f9efbdde0654ef0aa9b049 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <stdint.h>
 
+#include <QDebug>
+
 #include "deviceoptions.h"
 
 #include <pv/device/devinst.h>
@@ -46,7 +48,7 @@ namespace prop {
 namespace binding {
 
 DeviceOptions::DeviceOptions(shared_ptr<pv::device::DevInst> dev_inst,
-       const sr_probe_group *group) :
+       const sr_channel_group *group) :
        _dev_inst(dev_inst),
        _group(group)
 {
@@ -135,7 +137,11 @@ void DeviceOptions::bind_enum(const QString &name, int key,
        vector< pair<GVariant*, QString> > values;
 
        assert(_dev_inst);
-       assert(gvar_list);
+       if (!gvar_list) {
+               qDebug() << "Config key " << key << " was listed, but no "
+                       "options were given";
+               return;
+       }
 
        g_variant_iter_init (&iter, gvar_list);
        while ((gvar = g_variant_iter_next_value (&iter)))
@@ -157,22 +163,6 @@ void DeviceOptions::bind_int(const QString &name, int key, QString suffix,
                bind(&device::DevInst::set_config, _dev_inst, _group, key, _1))));
 }
 
-QString DeviceOptions::print_gvariant(GVariant *const gvar)
-{
-       QString s;
-
-       if (g_variant_is_of_type(gvar, G_VARIANT_TYPE("s")))
-               s = QString::fromUtf8(g_variant_get_string(gvar, NULL));
-       else
-       {
-               gchar *const text = g_variant_print(gvar, FALSE);
-               s = QString::fromUtf8(text);
-               g_free(text);
-       }
-
-       return s;
-}
-
 QString DeviceOptions::print_timebase(GVariant *const gvar)
 {
        uint64_t p, q;