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;
}
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),
const uint64_t end_sample = (uint64_t)max(
(double)0, end_time.convert_to<double>() * samplerate);
+ if ((start_sample == 0) && (end_sample == 0)) {
+ // Both cursors are negative and were clamped to 0
+ show_session_error(tr("Invalid Range"), tr("The cursors don't " \
+ "define a valid range of samples."));
+ return;
+ }
+
sample_range = make_pair(start_sample, end_sample);
} else {
sample_range = make_pair(0, 0);
// Construct the filter
const vector<string> exts = format->extensions();
- const QString filter = exts.empty() ? "" :
- tr("%1 files (*.%2)").arg(
- QString::fromStdString(format->description()),
- QString::fromStdString(join(exts, ", *.")));
+ const QString filter_exts = exts.empty() ? "" : QString::fromStdString("%1 (%2)").arg(
+ tr("%1 files").arg(QString::fromStdString(format->description())),
+ QString::fromStdString("*.%1").arg(QString::fromStdString(join(exts, " *."))));
+ const QString filter_all = QString::fromStdString("%1 (%2)").arg(
+ tr("All Files"), QString::fromStdString("*"));
+ const QString filter = QString::fromStdString("%1%2%3").arg(
+ exts.empty() ? "" : filter_exts,
+ exts.empty() ? "" : ";;",
+ filter_all);
// Show the file dialog
const QString file_name = QFileDialog::getOpenFileName(
- this, tr("Import File"), dir, tr(
- "%1 files (*);;All Files (*)").arg(
- QString::fromStdString(format->description())));
+ this, tr("Import File"), dir, filter);
if (file_name.isEmpty())
return;