From: Joel Holdsworth Date: Sat, 17 Jan 2015 18:14:41 +0000 (+0000) Subject: Session: Use set_device to select session file devices X-Git-Tag: pulseview-0.3.0~252 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=339e9524a80da7521796648bab4aa4a0ce6c7049;p=pulseview.git Session: Use set_device to select session file devices --- diff --git a/pv/session.cpp b/pv/session.cpp index 1f61c7db..751afb30 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -123,9 +123,12 @@ void Session::set_device(shared_ptr device) stop_capture(); // Are we setting a session device? - auto session_device = dynamic_pointer_cast(device); + const auto session_device = + dynamic_pointer_cast(device); + // Did we have a session device selected previously? - auto prev_session_device = dynamic_pointer_cast(device_); + const auto prev_session_device = + dynamic_pointer_cast(device_); if (device_) { session_->remove_datafeed_callbacks(); @@ -159,6 +162,7 @@ void Session::set_device(shared_ptr device) (shared_ptr device, shared_ptr packet) { data_feed_in(device, packet); }); + device_manager_.update_display_name(device); update_signals(device); } else device_ = nullptr; @@ -168,16 +172,9 @@ void Session::set_device(shared_ptr device) void Session::set_session_file(const string &name) { - session_ = device_manager_.context()->load_session(name); - device_ = session_->devices()[0]; - decode_traces_.clear(); - session_->add_datafeed_callback([=] - (shared_ptr device, shared_ptr packet) { - data_feed_in(device, packet); - }); - device_manager_.update_display_name(device_); - update_signals(device_); - device_selected(); + const shared_ptr session = + device_manager_.context()->load_session(name); + set_device(session->devices()[0]); } void Session::set_default_device()