]> sigrok.org Git - pulseview.git/commitdiff
DeviceToolButton: Support having no selected device
authorJoel Holdsworth <redacted>
Sun, 12 Apr 2015 15:10:05 +0000 (16:10 +0100)
committerUwe Hermann <redacted>
Thu, 11 Jun 2015 18:38:48 +0000 (20:38 +0200)
pv/widgets/devicetoolbutton.cpp

index 723542b9fd9d3c6f874e4494004ee1b64eb383f1..a0fc10e6f5a36de217cc2008cb1201e2f6bf0a02 100644 (file)
@@ -72,8 +72,8 @@ void DeviceToolButton::set_device_list(
        const list< shared_ptr<Device> > &devices, shared_ptr<Device> selected)
 {
        selected_device_ = selected;
-       setText(QString::fromStdString(
-               selected->display_name(device_manager_)));
+       setText(selected ? QString::fromStdString(
+               selected->display_name(device_manager_)) : "<No Device>");
        devices_ = vector< weak_ptr<Device> >(devices.begin(), devices.end());
        update_device_list();
 }
@@ -86,7 +86,7 @@ void DeviceToolButton::update_device_list()
        menu_.addSeparator();
 
        for (weak_ptr<Device> dev_weak_ptr : devices_) {
-               shared_ptr<Device> dev(dev_weak_ptr);
+               shared_ptr<Device> dev(dev_weak_ptr.lock());
                if (!dev)
                        continue;