]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/decodetrace.cpp
DecodeTrace: Prevent user from hiding the only row
[pulseview.git] / pv / views / trace / decodetrace.cpp
index 8ca8d580c8b4a4bb4fadf89e84421491fd567056..f4b9f3359ccbf35f41b845fb95842141c0e73afe 100644 (file)
@@ -1316,6 +1316,7 @@ void DecodeTrace::initialize_row_widgets(DecodeTraceRow* r, unsigned int row_id)
 
        // Add widgets inside the header container
        QCheckBox* cb = new QCheckBox();
+       r->row_visibility_checkbox = cb;
        header_container_layout->addWidget(cb);
        cb->setText(tr("Show this row"));
        cb->setChecked(r->decode_row->visible());
@@ -1426,6 +1427,10 @@ void DecodeTrace::update_rows()
                row_id++;
        }
 
+       // If there's only one row, it must not be hidden or else it can't be un-hidden
+       if (row_id == 1)
+               rows_.front().row_visibility_checkbox->setEnabled(false);
+
        // Remove any rows that no longer exist, obeying that iterators are invalidated
        bool any_exists;
        do {
@@ -1433,6 +1438,8 @@ void DecodeTrace::update_rows()
 
                for (unsigned int i = 0; i < rows_.size(); i++)
                        if (!rows_[i].exists) {
+                               delete rows_[i].row_visibility_checkbox;
+
                                for (QCheckBox* cb : rows_[i].selectors)
                                        delete cb;