- // Are we setting a session device?
- const auto session_device =
- dynamic_pointer_cast<SessionDevice>(device);
-
- // Did we have a session device selected previously?
- const auto prev_session_device =
- dynamic_pointer_cast<SessionDevice>(device_);
-
- if (device_) {
- session_->remove_datafeed_callbacks();
- if (!prev_session_device) {
- device_->close();
- session_->remove_devices();
- }
- }
-
- if (session_device)
- session_ = session_device->parent();
+ device_ = std::move(device);
+ device_->create();
+ device_->session()->add_datafeed_callback([=]
+ (shared_ptr<sigrok::Device> device, shared_ptr<Packet> packet) {
+ data_feed_in(device, packet);
+ });
+ update_signals();