From: Joel Holdsworth Date: Sun, 12 Apr 2015 15:10:05 +0000 (+0100) Subject: DeviceToolButton: Support having no selected device X-Git-Tag: pulseview-0.3.0~195 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2a53532cca7d8ac0b6e61413a9f69580f9f8c941;p=pulseview.git DeviceToolButton: Support having no selected device --- diff --git a/pv/widgets/devicetoolbutton.cpp b/pv/widgets/devicetoolbutton.cpp index 723542b9..a0fc10e6 100644 --- a/pv/widgets/devicetoolbutton.cpp +++ b/pv/widgets/devicetoolbutton.cpp @@ -72,8 +72,8 @@ void DeviceToolButton::set_device_list( const list< shared_ptr > &devices, shared_ptr selected) { selected_device_ = selected; - setText(QString::fromStdString( - selected->display_name(device_manager_))); + setText(selected ? QString::fromStdString( + selected->display_name(device_manager_)) : ""); devices_ = vector< weak_ptr >(devices.begin(), devices.end()); update_device_list(); } @@ -86,7 +86,7 @@ void DeviceToolButton::update_device_list() menu_.addSeparator(); for (weak_ptr dev_weak_ptr : devices_) { - shared_ptr dev(dev_weak_ptr); + shared_ptr dev(dev_weak_ptr.lock()); if (!dev) continue;