}
}
+void MainWindow::select_device(shared_ptr<Device> device)
+{
+ try {
+ session_.set_device(device);
+ } catch(const QString &e) {
+ QMessageBox msg(this);
+ msg.setText(e);
+ msg.setInformativeText(tr("Failed to Select Device"));
+ msg.setStandardButtons(QMessageBox::Ok);
+ msg.setIcon(QMessageBox::Warning);
+ msg.exec();
+ }
+}
+
void MainWindow::setup_ui()
{
setObjectName(QString::fromUtf8("MainWindow"));
device = device_manager_.find_device_from_info(dev_info);
if (device) {
- session_.set_device(device);
+ select_device(device);
update_device_list();
}
// If the user selected a device, select it in the device list. Select the
// current device otherwise.
if (dlg.exec())
- session_.set_device(dlg.get_selected_device());
+ select_device(dlg.get_selected_device());
update_device_list();
}
if (session_device)
session_ = session_device->parent();
- device_ = device;
decode_traces_.clear();
if (device) {
if (!session_device)
{
session_ = device_manager_.context()->create_session();
- device->open();
+
+ 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();
}