]> sigrok.org Git - pulseview.git/commitdiff
Session: Made update_signals handle having a missing device gracefully
authorJoel Holdsworth <redacted>
Mon, 6 Apr 2015 09:14:30 +0000 (10:14 +0100)
committerUwe Hermann <redacted>
Thu, 11 Jun 2015 18:38:47 +0000 (20:38 +0200)
pv/session.cpp

index 2cdc25f83ed0ee3c718896da9d8df98d13f34876..542b88b798188696eabc216947065bf5f43c06ce 100644 (file)
@@ -306,8 +306,15 @@ void Session::update_signals(shared_ptr<devices::Device> device)
        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
-       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) {
@@ -334,7 +341,7 @@ void Session::update_signals(shared_ptr<devices::Device> device)
                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