X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fdecodetrace.cpp;h=c451635fbd6c3b86830f1a7b6fa17e24981e988f;hb=8b24af15d583c1df24b49f9709ff9156a9faa16e;hp=8ca8d580c8b4a4bb4fadf89e84421491fd567056;hpb=440bdf504a05efe589e8954ad28be62ba2c2d325;p=pulseview.git diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp index 8ca8d580..c451635f 100644 --- a/pv/views/trace/decodetrace.cpp +++ b/pv/views/trace/decodetrace.cpp @@ -242,10 +242,21 @@ shared_ptr DecodeTrace::base() const return base_; } +void DecodeTrace::set_owner(TraceTreeItemOwner *owner) +{ + Trace::set_owner(owner); + + // The owner is set in trace::View::signals_changed(), which is a slot. + // So after this trace was added to the view, we won't have an owner + // that we need to initialize in update_rows(). Once we do, we call it + // from on_decode_reset(). + on_decode_reset(); +} + pair DecodeTrace::v_extents() const { // Make an empty decode trace appear symmetrical - if (max_visible_rows_ == 0) + if (visible_rows_ == 0) return make_pair(-default_row_height_, default_row_height_); unsigned int height = 0; @@ -1316,6 +1327,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()); @@ -1377,6 +1389,9 @@ void DecodeTrace::initialize_row_widgets(DecodeTraceRow* r, unsigned int row_id) void DecodeTrace::update_rows() { + if (!owner_) + return; + lock_guard lock(row_modification_mutex_); for (DecodeTraceRow& r : rows_) @@ -1426,6 +1441,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 +1452,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; @@ -1813,7 +1834,7 @@ void DecodeTrace::on_animation_timer() if (r.expanding) { if (r.height < r.expanded_height) { r.anim_height += height_delta / (float)AnimationDurationInTicks; - r.height = r.anim_height; + r.height = min((int)r.anim_height, (int)r.expanded_height); r.anim_shape += ArrowSize / (float)AnimationDurationInTicks; animation_finished = false; } else @@ -1823,7 +1844,7 @@ void DecodeTrace::on_animation_timer() if (r.collapsing) { if (r.height > default_row_height_) { r.anim_height -= height_delta / (float)AnimationDurationInTicks; - r.height = r.anim_height; + r.height = max((int)r.anim_height, (int)0); r.anim_shape -= ArrowSize / (float)AnimationDurationInTicks; animation_finished = false; } else