]> sigrok.org Git - pulseview.git/blobdiff - pv/session.cpp
session: add support to auto detect input format (for init file)
[pulseview.git] / pv / session.cpp
index 87e9b3a5e1060223d27a67f0a17cab94db6e9fcc..50e89e567041c2ec186e47e0d387457808f452a3 100644 (file)
@@ -301,7 +301,8 @@ void Session::restore_settings(QSettings &settings)
                        set_device(device);
 
                        start_capture([](QString infoMessage) {
-                               qDebug().noquote() << "Session error:" << infoMessage; });
+                               // TODO Emulate noquote()
+                               qDebug() << "Session error:" << infoMessage; });
 
                        set_name(QFileInfo(filename).fileName());
                }
@@ -482,6 +483,7 @@ void Session::load_init_file(const string &file_name, const string &format)
        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, ":");
@@ -498,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);