From: Wolfram Sang Date: Tue, 6 Mar 2018 13:48:54 +0000 (+0100) Subject: Fix #928 by catching errors if config_list() fails X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=519a6ed82d88f63fe5353f84ec9ebb775d1e9e95;p=pulseview.git Fix #928 by catching errors if config_list() fails 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 --- diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 34b120fe..0bb4c454 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -313,7 +313,11 @@ void MainBar::update_sample_rate_selector() const shared_ptr 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),