]> sigrok.org Git - pulseview.git/commitdiff
Fix #928 by catching errors if config_list() fails
authorWolfram Sang <redacted>
Tue, 6 Mar 2018 13:48:54 +0000 (14:48 +0100)
committerSoeren Apel <redacted>
Tue, 6 Mar 2018 18:16:26 +0000 (19:16 +0100)
MainBar::config_list() may fail so catch errors and don't segfault.
Discovered using an OLS with unknown firmware not supporting metadata.

Signed-off-by: Wolfram Sang <redacted>
pv/toolbars/mainbar.cpp

index 34b120fec11ce0ec14bf21f16cc717e7b9d74222..0bb4c4541cc704f50420c06324ec0fa9de83686c 100644 (file)
@@ -313,7 +313,11 @@ void MainBar::update_sample_rate_selector()
        const shared_ptr<sigrok::Device> sr_dev = device->device();
 
        if (sr_dev->config_check(ConfigKey::SAMPLERATE, Capability::LIST)) {
-               gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
+               try {
+                       gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
+               } catch (Error error) {
+                       qDebug() << tr("Failed to get sample rate list:") << error.what();
+               }
        } else {
                sample_rate_.show_none();
                updating_sample_rate_ = false;
@@ -413,10 +417,14 @@ void MainBar::update_sample_count_selector()
        }
 
        if (sr_dev->config_check(ConfigKey::LIMIT_SAMPLES, Capability::LIST)) {
-               auto gvar = sr_dev->config_list(ConfigKey::LIMIT_SAMPLES);
-               if (gvar.gobj())
-                       g_variant_get(gvar.gobj(), "(tt)",
-                               &min_sample_count, &max_sample_count);
+               try {
+                       auto gvar = sr_dev->config_list(ConfigKey::LIMIT_SAMPLES);
+                       if (gvar.gobj())
+                               g_variant_get(gvar.gobj(), "(tt)",
+                                       &min_sample_count, &max_sample_count);
+               } catch (Error error) {
+                       qDebug() << tr("Failed to get sample limit list:") << error.what();
+               }
        }
 
        min_sample_count = min(max(min_sample_count, MinSampleCount),