SamplingBar: Handle a failure to list the SAMPLERATE key
authorJoel Holdsworth <joel@airwebreathe.org.uk>
Mon, 5 Jan 2015 20:10:44 +0000 (20:10 +0000)
committerJoel Holdsworth <joel@airwebreathe.org.uk>
Mon, 5 Jan 2015 20:13:41 +0000 (20:13 +0000)
This fixes #529

pv/toolbars/samplingbar.cpp

index 7ee4d98150b5ccdb491ff9e2093a3507a9e7ad0d..8c1b3c6d17691a42a1ee4dd80cbbf7d23ae106b4 100644 (file)
@@ -183,8 +183,17 @@ void SamplingBar::update_sample_rate_selector()
        const auto iter = keys.find(ConfigKey::SAMPLERATE);
        if (iter != keys.end() &&
                (*iter).second.find(sigrok::LIST) != (*iter).second.end()) {
-               gvar_dict = device->config_list(ConfigKey::SAMPLERATE);
-       } else {
+               const auto keys = device->config_keys(
+                       ConfigKey::DEVICE_OPTIONS);
+               try {
+                       gvar_dict = device->config_list(ConfigKey::SAMPLERATE);
+               } catch(const sigrok::Error &e) {
+                       // Failed to enunmerate samplerate
+                       (void)e;
+               }
+       }
+
+       if (!gvar_dict) {
                sample_rate_.show_none();
                updating_sample_rate_ = false;
                return;