From d7168e582c71ebcc359b12efed83daa2a6b6f28e Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sun, 13 May 2018 08:59:02 +0200 Subject: [PATCH] session: add support to auto detect input format (for init file) Extend the Session::load_init_file() method, to have the input format automatically detected in the absence of an -I spec upon startup. This fixes part of bug 1015. Input files specified at the command line when pulseview gets invoked are handled. Files that interactively get loaded while pulseview is running are not handled yet. --- pv/session.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pv/session.cpp b/pv/session.cpp index 80dad66e..50e89e56 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -483,6 +483,7 @@ void Session::load_init_file(const string &file_name, const string &format) map input_opts; if (!format.empty()) { + // Got a user provided input format spec. const map > formats = device_manager_.context()->input_formats(); auto user_opts = pv::util::split_string(format, ":"); @@ -499,6 +500,11 @@ void Session::load_init_file(const string &file_name, const string &format) 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); -- 2.30.2