projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Session: Made update_signals handle having a missing device gracefully
[pulseview.git]
/
pv
/
session.cpp
diff --git
a/pv/session.cpp
b/pv/session.cpp
index 27154d13cd238c8713e4aab4f5415fa773cbd123..542b88b798188696eabc216947065bf5f43c06ce 100644
(file)
--- a/
pv/session.cpp
+++ b/
pv/session.cpp
@@
-133,7
+133,6
@@
void Session::set_device(shared_ptr<devices::Device> device)
(shared_ptr<sigrok::Device> device, shared_ptr<Packet> packet) {
data_feed_in(device, packet);
});
(shared_ptr<sigrok::Device> device, shared_ptr<Packet> packet) {
data_feed_in(device, packet);
});
- device_manager_.update_display_name(device_);
update_signals(device_);
decode_traces_.clear();
update_signals(device_);
decode_traces_.clear();
@@
-307,8
+306,15
@@
void Session::update_signals(shared_ptr<devices::Device> device)
assert(device);
assert(capture_state_ == Stopped);
assert(device);
assert(capture_state_ == Stopped);
+ const shared_ptr<sigrok::Device> sr_dev = device->device();
+ if (!sr_dev) {
+ signals_.clear();
+ logic_data_.reset();
+ return;
+ }
+
// Detect what data types we will receive
// Detect what data types we will receive
- auto channels =
device->device()
->channels();
+ auto channels =
sr_dev
->channels();
unsigned int logic_channel_count = std::count_if(
channels.begin(), channels.end(),
[] (shared_ptr<Channel> channel) {
unsigned int logic_channel_count = std::count_if(
channels.begin(), channels.end(),
[] (shared_ptr<Channel> channel) {
@@
-335,7
+341,7
@@
void Session::update_signals(shared_ptr<devices::Device> device)
unordered_set< shared_ptr<view::Signal> > prev_sigs(signals_);
signals_.clear();
unordered_set< shared_ptr<view::Signal> > prev_sigs(signals_);
signals_.clear();
- for (auto channel :
device->device()
->channels()) {
+ for (auto channel :
sr_dev
->channels()) {
shared_ptr<view::Signal> signal;
// Find the channel in the old signals
shared_ptr<view::Signal> signal;
// Find the channel in the old signals
@@
-401,7
+407,12
@@
shared_ptr<view::Signal> Session::signal_from_channel(
void Session::read_sample_rate(shared_ptr<sigrok::Device> device)
{
assert(device);
void Session::read_sample_rate(shared_ptr<sigrok::Device> device)
{
assert(device);
- const auto keys = device->config_keys(ConfigKey::DEVICE_OPTIONS);
+ map< const ConfigKey*, set<sigrok::Capability> > keys;
+
+ try {
+ keys = device->config_keys(ConfigKey::DEVICE_OPTIONS);
+ } catch (const Error) {}
+
const auto iter = keys.find(ConfigKey::SAMPLERATE);
cur_samplerate_ = (iter != keys.end() &&
(*iter).second.find(sigrok::GET) != (*iter).second.end()) ?
const auto iter = keys.find(ConfigKey::SAMPLERATE);
cur_samplerate_ = (iter != keys.end() &&
(*iter).second.find(sigrok::GET) != (*iter).second.end()) ?