]> sigrok.org Git - pulseview.git/commitdiff
Session: Use set_device to select session file devices
authorJoel Holdsworth <redacted>
Sat, 17 Jan 2015 18:14:41 +0000 (18:14 +0000)
committerUwe Hermann <redacted>
Tue, 27 Jan 2015 15:28:31 +0000 (16:28 +0100)
pv/session.cpp

index 1f61c7db4bde41a690398e19347e65ca6c031b46..751afb30bd746abb7fe95fa20a35dcce9a232149 100644 (file)
@@ -123,9 +123,12 @@ void Session::set_device(shared_ptr<Device> device)
        stop_capture();
 
        // Are we setting a session device?
-       auto session_device = dynamic_pointer_cast<SessionDevice>(device);
+       const auto session_device =
+               dynamic_pointer_cast<SessionDevice>(device);
+
        // Did we have a session device selected previously?
-       auto prev_session_device = dynamic_pointer_cast<SessionDevice>(device_);
+       const auto prev_session_device =
+               dynamic_pointer_cast<SessionDevice>(device_);
 
        if (device_) {
                session_->remove_datafeed_callbacks();
@@ -159,6 +162,7 @@ void Session::set_device(shared_ptr<Device> device)
                        (shared_ptr<Device> device, shared_ptr<Packet> 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> 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> device, shared_ptr<Packet> packet) {
-                       data_feed_in(device, packet);
-               });
-       device_manager_.update_display_name(device_);
-       update_signals(device_);
-       device_selected();
+       const shared_ptr<sigrok::Session> session =
+               device_manager_.context()->load_session(name);
+       set_device(session->devices()[0]);
 }
 
 void Session::set_default_device()