]> sigrok.org Git - pulseview.git/blobdiff - pv/popups/channels.cpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / popups / channels.cpp
index b7fcad4584bdd1a5f82042c4955afa84648f1d3d..ce2e8e98e08e0f7f3e88356b68ddce4aad1d4c66 100644 (file)
@@ -158,8 +158,13 @@ Channels::Channels(Session &session, QWidget *parent) :
        layout_.addRow(&filter_buttons_bar_);
 
        // Connect the check-box signal mapper
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+       connect(&check_box_mapper_, SIGNAL(mappedObject(QObject*)),
+               this, SLOT(on_channel_checked(QObject*)));
+#else
        connect(&check_box_mapper_, SIGNAL(mapped(QWidget*)),
                this, SLOT(on_channel_checked(QWidget*)));
+#endif
 }
 
 void Channels::set_all_channels(bool set)
@@ -272,14 +277,14 @@ void Channels::populate_group(shared_ptr<ChannelGroup> group,
                        if (sigs.size() > 8) {
                                QPushButton *row_enable_button = new QPushButton(tr("All"), this);
                                grid->addWidget(row_enable_button, row, 8);
-                               connect(row_enable_button, &QPushButton::clicked,
-                                               [this_row]() {
-                                       for (QCheckBox *box : this_row)
-                                               box->setChecked(true);
+                               connect(row_enable_button, &QPushButton::clicked, row_enable_button,
+                                       [this_row]() {
+                                               for (QCheckBox *box : this_row)
+                                                       box->setChecked(true);
                                        });
 
                                QPushButton *row_disable_button = new QPushButton(tr("None"), this);
-                               connect(row_disable_button, &QPushButton::clicked,
+                               connect(row_disable_button, &QPushButton::clicked, row_disable_button,
                                                [this_row]() {
                                        for (QCheckBox *box : this_row)
                                                box->setChecked(false);
@@ -302,14 +307,16 @@ void Channels::populate_group(shared_ptr<ChannelGroup> group,
                group_layout->addWidget(btn_enable_all);
                group_layout->addWidget(btn_disable_all);
 
-               connect(btn_enable_all, &QPushButton::clicked, [group_checkboxes](){
-                       for (QCheckBox *box: group_checkboxes)
-                               box->setChecked(true);
+               connect(btn_enable_all, &QPushButton::clicked, btn_enable_all,
+                       [group_checkboxes](){
+                               for (QCheckBox *box: group_checkboxes)
+                                       box->setChecked(true);
                        });
 
-               connect(btn_disable_all, &QPushButton::clicked, [group_checkboxes](){
-                       for (QCheckBox *box: group_checkboxes)
-                               box->setChecked(false);
+               connect(btn_disable_all, &QPushButton::clicked, btn_disable_all,
+                       [group_checkboxes](){
+                               for (QCheckBox *box: group_checkboxes)
+                                       box->setChecked(false);
                        });
        }
 
@@ -331,11 +338,9 @@ void Channels::showEvent(QShowEvent *event)
        for (auto& entry : device->channel_groups()) {
                const shared_ptr<ChannelGroup> group = entry.second;
 
-               try {
-                       QLabel* label = group_label_map_.at(group);
+               if (group_label_map_.count(group) > 0) {
+                       QLabel* label = group_label_map_[group];
                        label->setText(QString("<h3>%1</h3>").arg(group->name().c_str()));
-               } catch (out_of_range&) {
-                       // Do nothing
                }
        }
 
@@ -354,7 +359,11 @@ void Channels::showEvent(QShowEvent *event)
        updating_channels_ = false;
 }
 
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+void Channels::on_channel_checked(QObject *widget)
+#else
 void Channels::on_channel_checked(QWidget *widget)
+#endif
 {
        if (updating_channels_)
                return;