]> sigrok.org Git - pulseview.git/blobdiff - pv/widgets/devicetoolbutton.cpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / widgets / devicetoolbutton.cpp
index bb18b792788cd3592eba4b46ddcb967cd17e89a7..2e76f689a61f448b068e149e2c1886a5f67992b8 100644 (file)
@@ -55,8 +55,13 @@ DeviceToolButton::DeviceToolButton(QWidget *parent,
        setDefaultAction(connect_action_);
        setMinimumWidth(QFontMetrics(font()).averageCharWidth() * 24);
 
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+       connect(&mapper_, SIGNAL(mappedObject(QObject*)),
+               this, SLOT(on_action(QObject*)));
+#else
        connect(&mapper_, SIGNAL(mapped(QObject*)),
                this, SLOT(on_action(QObject*)));
+#endif
 
        connect(&menu_, SIGNAL(hovered(QAction*)),
                this, SLOT(on_menu_hovered(QAction*)));
@@ -91,7 +96,7 @@ void DeviceToolButton::update_device_list()
        menu_.setDefaultAction(connect_action_);
        menu_.addSeparator();
 
-       for (weak_ptr<Device> dev_weak_ptr : devices_) {
+       for (weak_ptr<Device>& dev_weak_ptr : devices_) {
                shared_ptr<Device> dev(dev_weak_ptr.lock());
                if (!dev)
                        continue;
@@ -100,7 +105,7 @@ void DeviceToolButton::update_device_list()
                        dev->display_name(device_manager_)), this);
                a->setCheckable(true);
                a->setChecked(selected_device_ == dev);
-               a->setData(qVariantFromValue((void*)dev.get()));
+               a->setData(QVariant::fromValue((void*)dev.get()));
                a->setToolTip(QString::fromStdString(dev->full_name()));
                mapper_.setMapping(a, a);
 
@@ -117,7 +122,7 @@ void DeviceToolButton::on_action(QObject *action)
        selected_device_.reset();
 
        Device *const dev = (Device*)((QAction*)action)->data().value<void*>();
-       for (weak_ptr<Device> dev_weak_ptr : devices_) {
+       for (weak_ptr<Device>& dev_weak_ptr : devices_) {
                shared_ptr<Device> dev_ptr(dev_weak_ptr);
                if (dev_ptr.get() == dev) {
                        selected_device_ = shared_ptr<Device>(dev_ptr);