- if (dev_inst) {
- dev_inst->use(this);
- sr_session_datafeed_callback_add(_sr_session, data_feed_in_proc, NULL);
- update_signals(dev_inst);
- }
+ decode_traces_.clear();
+
+ if (device) {
+ if (!session_device)
+ {
+ 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);
+ });
+ update_signals(device);
+ } else
+ device_ = nullptr;
+
+ device_selected();