X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=ebef90cbb6590fb9961fad97f73047e56e8acc79;hp=7545da3c15030a7090974f1ee65ee4f413c2e44a;hb=03cc651d78a85308107e0ef3e5e514503d7c723c;hpb=2ad82c2e40b6865481733913a2c32735602f63c4 diff --git a/pv/session.cpp b/pv/session.cpp index 7545da3c..ebef90cb 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -138,16 +138,21 @@ void Session::set_device(shared_ptr device) if (device_) device_->close(); + device_.reset(); + + // Remove all traces + signals_.clear(); + decode_traces_.clear(); + signals_changed(); + device_ = std::move(device); device_->open(); device_->session()->add_datafeed_callback([=] (shared_ptr device, shared_ptr packet) { data_feed_in(device, packet); }); - update_signals(); - - decode_traces_.clear(); + update_signals(); device_selected(); } @@ -333,7 +338,11 @@ void Session::set_capture_state(capture_state state) void Session::update_signals() { - assert(device_); + if (!device_) { + signals_.clear(); + logic_data_.reset(); + return; + } lock_guard lock(data_mutex_); @@ -581,7 +590,7 @@ void Session::feed_in_analog(shared_ptr analog) if (iter != cur_analog_segments_.end()) segment = (*iter).second; else { - // If no segment was found, this means we havn't + // If no segment was found, this means we haven't // created one yet. i.e. this is the first packet // in the sweep containing this segment. sweep_beginning = true;