]> sigrok.org Git - pulseview.git/blobdiff - pv/toolbars/samplingbar.cpp
SamplingBar: Handle a failure to list the LIMIT_SAMPLES key
[pulseview.git] / pv / toolbars / samplingbar.cpp
index 7ee4d98150b5ccdb491ff9e2093a3507a9e7ad0d..710f3128af727cf4ef51ce90178d6efaa94f3ab6 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;
@@ -284,9 +293,16 @@ void SamplingBar::update_sample_count_selector()
        const auto iter = keys.find(ConfigKey::LIMIT_SAMPLES);
        if (iter != keys.end() &&
                (*iter).second.find(sigrok::LIST) != (*iter).second.end()) {
-               auto gvar = device->config_list(ConfigKey::LIMIT_SAMPLES);
-               g_variant_get(gvar.gobj(), "(tt)",
-                       &min_sample_count, &max_sample_count);
+               try {
+                       auto gvar =
+                               device->config_list(ConfigKey::LIMIT_SAMPLES);
+                       if (gvar)
+                               g_variant_get(gvar.gobj(), "(tt)",
+                                       &min_sample_count, &max_sample_count);
+               } catch(const sigrok::Error &e) {
+                       // Failed to query sample limit
+                       (void)e;
+               }
        }
 
        min_sample_count = min(max(min_sample_count, MinSampleCount),