Move the format match logic from load_init_file() to load_file(), so
that it transparently takes effect on each "opened" file. Users still
can choose to "import" files and specify options when required. In the
case of lookup miss, sigrok session is assumed as before.
This fixes the remainder of bug #1015.
map<string, Glib::VariantBase> input_opts;
if (!format.empty()) {
map<string, Glib::VariantBase> input_opts;
if (!format.empty()) {
- // Got a user provided input format spec.
const map<string, shared_ptr<InputFormat> > formats =
device_manager_.context()->input_formats();
auto user_opts = pv::util::split_string(format, ":");
const map<string, shared_ptr<InputFormat> > formats =
device_manager_.context()->input_formats();
auto user_opts = pv::util::split_string(format, ":");
input_format = (*iter).second;
input_opts = input_format_options(user_opts,
input_format->options());
input_format = (*iter).second;
input_opts = input_format_options(user_opts,
input_format->options());
- } else {
- // (Try to) auto detect the input format. Lookup failure
- // is not fatal, when no input module claimed responsibility,
- // then a session file gets loaded.
- input_format = device_manager_.context()->input_format_match(file_name);
}
load_file(QString::fromStdString(file_name), input_format, input_opts);
}
load_file(QString::fromStdString(file_name), input_format, input_opts);
const QString errorMessage(
QString("Failed to load file %1").arg(file_name));
const QString errorMessage(
QString("Failed to load file %1").arg(file_name));
+ // In the absence of a caller's format spec, try to auto detect.
+ // Assume "sigrok session file" upon lookup miss.
+ if (!format)
+ format = device_manager_.context()->input_format_match(file_name.toStdString());
try {
if (format)
set_device(shared_ptr<devices::Device>(
try {
if (format)
set_device(shared_ptr<devices::Device>(