- if (device) {
- // Are we setting a session device?
- const auto session_device =
- dynamic_pointer_cast<SessionDevice>(device);
-
- if (session_device)
- session_ = session_device->parent();
- else {
- session_ = device_manager_.context()->create_session();
-
- try {
- device->open();
- } catch(const sigrok::Error &e) {
- throw QString(e.what());
- }
-
- session_->add_device(device);
- }
-
- device_ = device;
- 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);
- } else
- device_ = nullptr;
-