From: Joel Holdsworth Date: Mon, 6 Apr 2015 09:14:30 +0000 (+0100) Subject: Session: Made update_signals handle having a missing device gracefully X-Git-Tag: pulseview-0.3.0~208 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=c6412b47eb1f5529fd76247caa7de09b6c9693d5 Session: Made update_signals handle having a missing device gracefully --- diff --git a/pv/session.cpp b/pv/session.cpp index 2cdc25f8..542b88b7 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -306,8 +306,15 @@ void Session::update_signals(shared_ptr device) assert(device); assert(capture_state_ == Stopped); + const shared_ptr sr_dev = device->device(); + if (!sr_dev) { + signals_.clear(); + logic_data_.reset(); + return; + } + // 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) { @@ -334,7 +341,7 @@ void Session::update_signals(shared_ptr device) unordered_set< shared_ptr > prev_sigs(signals_); signals_.clear(); - for (auto channel : device->device()->channels()) { + for (auto channel : sr_dev->channels()) { shared_ptr signal; // Find the channel in the old signals