projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
session: apply input format match to interactively loaded files, too
[pulseview.git]
/
pv
/
session.cpp
diff --git
a/pv/session.cpp
b/pv/session.cpp
index cbf24e235acc274c478c79481bfc5b446c80939f..6767951cf85961ea303d9fc6f830e8a7d9eb576d 100644
(file)
--- a/
pv/session.cpp
+++ b/
pv/session.cpp
@@
-28,6
+28,7
@@
#include <sys/stat.h>
#include "devicemanager.hpp"
#include <sys/stat.h>
#include "devicemanager.hpp"
+#include "mainwindow.hpp"
#include "session.hpp"
#include "data/analog.hpp"
#include "session.hpp"
#include "data/analog.hpp"
@@
-300,7
+301,8
@@
void Session::restore_settings(QSettings &settings)
set_device(device);
start_capture([](QString infoMessage) {
set_device(device);
start_capture([](QString infoMessage) {
- qDebug().noquote() << "Session error:" << infoMessage; });
+ // TODO Emulate noquote()
+ qDebug() << "Session error:" << infoMessage; });
set_name(QFileInfo(filename).fileName());
}
set_name(QFileInfo(filename).fileName());
}
@@
-352,7
+354,7
@@
void Session::select_device(shared_ptr<devices::Device> device)
else
set_default_device();
} catch (const QString &e) {
else
set_default_device();
} catch (const QString &e) {
-
main_bar_->
session_error(tr("Failed to select device"), e);
+
MainWindow::show_
session_error(tr("Failed to select device"), e);
}
}
}
}
@@
-400,7
+402,7
@@
void Session::set_device(shared_ptr<devices::Device> device)
device_->open();
} catch (const QString &e) {
device_.reset();
device_->open();
} catch (const QString &e) {
device_.reset();
-
main_bar_->
session_error(tr("Failed to open device"), e);
+
MainWindow::show_
session_error(tr("Failed to open device"), e);
}
if (device_) {
}
if (device_) {
@@
-490,7
+492,7
@@
void Session::load_init_file(const string &file_name, const string &format)
[&](const pair<string, shared_ptr<InputFormat> > f) {
return f.first == user_name; });
if (iter == formats.end()) {
[&](const pair<string, shared_ptr<InputFormat> > f) {
return f.first == user_name; });
if (iter == formats.end()) {
-
main_bar_->
session_error(tr("Error"),
+
MainWindow::show_
session_error(tr("Error"),
tr("Unexpected input format: %s").arg(QString::fromStdString(format)));
return;
}
tr("Unexpected input format: %s").arg(QString::fromStdString(format)));
return;
}
@@
-509,6
+511,10
@@
void Session::load_file(QString file_name,
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>(
@@
-522,7
+528,7
@@
void Session::load_file(QString file_name,
device_manager_.context(),
file_name.toStdString())));
} catch (Error& e) {
device_manager_.context(),
file_name.toStdString())));
} catch (Error& e) {
-
main_bar_->
session_error(tr("Failed to load ") + file_name, e.what());
+
MainWindow::show_
session_error(tr("Failed to load ") + file_name, e.what());
set_default_device();
main_bar_->update_device_list();
return;
set_default_device();
main_bar_->update_device_list();
return;
@@
-531,7
+537,7
@@
void Session::load_file(QString file_name,
main_bar_->update_device_list();
start_capture([&, errorMessage](QString infoMessage) {
main_bar_->update_device_list();
start_capture([&, errorMessage](QString infoMessage) {
-
main_bar_->
session_error(errorMessage, infoMessage); });
+
MainWindow::show_
session_error(errorMessage, infoMessage); });
set_name(QFileInfo(file_name).fileName());
}
set_name(QFileInfo(file_name).fileName());
}