From: Joel Holdsworth Date: Sun, 12 Apr 2015 15:12:55 +0000 (+0100) Subject: View: Support having no selected device X-Git-Tag: pulseview-0.3.0~194 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e37e05f7f0b20076b21cf5644dc94915111facdb;p=pulseview.git View: Support having no selected device --- 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