From e37e05f7f0b20076b21cf5644dc94915111facdb Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sun, 12 Apr 2015 16:12:55 +0100 Subject: [PATCH] View: Support having no selected device --- pv/view/view.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 67d4f404..695d5f9f 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -676,8 +676,12 @@ void View::signals_changed() // Populate the traces clear_child_items(); - shared_ptr device = session_.device()->device(); - assert(device); + const auto device = session_.device(); + if (!device) + return; + + shared_ptr sr_dev = device->device(); + assert(sr_dev); // Collect a set of signals unordered_map, shared_ptr > @@ -690,7 +694,7 @@ void View::signals_changed() signal_map[sig->channel()] = sig; // Populate channel groups - for (auto entry : device->channel_groups()) + for (auto entry : sr_dev->channel_groups()) { const shared_ptr &group = entry.second; @@ -711,7 +715,7 @@ void View::signals_changed() shared_ptr logic_trace_group(new TraceGroup()); int child_offset = 0; - if (add_channels_to_owner(device->channels(), + if (add_channels_to_owner(sr_dev->channels(), logic_trace_group.get(), child_offset, signal_map, [](shared_ptr r) -> bool { return dynamic_pointer_cast(r) != nullptr; @@ -723,7 +727,7 @@ void View::signals_changed() } // Add the remaining channels - add_channels_to_owner(device->channels(), this, offset, signal_map); + add_channels_to_owner(sr_dev->channels(), this, offset, signal_map); assert(signal_map.empty()); // Add decode signals -- 2.30.2