{
// Set the title to include the device/file name
const shared_ptr<devices::Device> device = session_.device();
- if (!device)
+
+ if (!device) {
+ main_bar_->reset_device_selector();
return;
+ }
const string display_name = device->display_name(device_manager_);
setWindowTitle(tr("%1 - PulseView").arg(display_name.c_str()));
signals_changed();
device_ = std::move(device);
- device_->open();
+
+ try {
+ device_->open();
+ } catch (const QString &e) {
+ device_.reset();
+ device_selected();
+ throw;
+ }
+
device_->session()->add_datafeed_callback([=]
(shared_ptr<sigrok::Device> device, shared_ptr<Packet> packet) {
data_feed_in(device, packet);
sample_rate_.setEnabled(ui_enabled);
}
+void MainBar::reset_device_selector()
+{
+ device_selector_.reset();
+}
+
void MainBar::update_sample_rate_selector()
{
Glib::VariantContainerBase gvar_dict;
void set_capture_state(pv::Session::capture_state state);
+ void reset_device_selector();
+
private:
void update_sample_rate_selector();
void update_sample_rate_selector_value();
{
selected_device_ = selected;
setText(selected ? QString::fromStdString(
- selected->display_name(device_manager_)) : "<No Device>");
+ selected->display_name(device_manager_)) : tr("<No Device>"));
devices_ = vector< weak_ptr<Device> >(devices.begin(), devices.end());
update_device_list();
}
+void DeviceToolButton::reset()
+{
+ setText(tr("<No Device>"));
+ selected_device_.reset();
+ update_device_list();
+}
+
void DeviceToolButton::update_device_list()
{
menu_.clear();
{
assert(action);
+ selected_device_.reset();
+
Device *const dev = (Device*)((QAction*)action)->data().value<void*>();
for (weak_ptr<Device> dev_weak_ptr : devices_) {
shared_ptr<Device> dev_ptr(dev_weak_ptr);
const std::list< std::shared_ptr<devices::Device> > &devices,
std::shared_ptr<devices::Device> selected);
+ /**
+ * Sets the current device to "no device". Useful for when a selected
+ * device fails to open.
+ */
+ void reset();
+
private:
/**
* Repopulates the menu from the device list.