X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fviews%2Ftabular_decoder%2Fmodel.cpp;h=e7a199f13da19248016e61e16d4c9065e1ac589f;hb=b36ba61198551c5994c9b3210b07109ac0d87829;hp=3733e13828afdd8b06775744cc7a8215fe05b582;hpb=6f43db70c63c683d546566eda0be7f182f614655;p=pulseview.git diff --git a/pv/views/tabular_decoder/model.cpp b/pv/views/tabular_decoder/model.cpp index 3733e138..e7a199f1 100644 --- a/pv/views/tabular_decoder/model.cpp +++ b/pv/views/tabular_decoder/model.cpp @@ -164,8 +164,11 @@ uint8_t AnnotationCollectionModel::first_hidden_column() const QVariant AnnotationCollectionModel::headerData(int section, Qt::Orientation orientation, int role) const { + if ((section < 0) || (section >= (int)header_data_.size())) + return QVariant(); + if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)) - return header_data_.at(section); + return header_data_[section]; return QVariant(); } @@ -213,6 +216,8 @@ int AnnotationCollectionModel::columnCount(const QModelIndex& parent_idx) const void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signal, uint32_t current_segment) { + layoutAboutToBeChanged(); + if (!signal) { all_annotations_ = nullptr; dataset_ = nullptr; @@ -232,9 +237,10 @@ void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signa connect(dec.get(), SIGNAL(annotation_visibility_changed()), this, SLOT(on_annotation_visibility_changed())); - if (hide_hidden_) + if (hide_hidden_) { update_annotations_without_hidden(); - else + dataset_ = &all_annotations_without_hidden_; + } else dataset_ = all_annotations_; if (!dataset_ || dataset_->empty()) { @@ -262,6 +268,8 @@ void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signa void AnnotationCollectionModel::set_hide_hidden(bool hide_hidden) { + layoutAboutToBeChanged(); + hide_hidden_ = hide_hidden; if (hide_hidden_) { @@ -320,9 +328,9 @@ QModelIndex AnnotationCollectionModel::update_highlighted_rows(QModelIndex first // we would need to highlight - only then do we do so QModelIndex index = first; do { - const Annotation* ann = - static_cast(index.internalPointer()); - assert(ann); + const Annotation* ann = static_cast(index.internalPointer()); + if (!ann) // Can happen if the table is being modified at this exact time + return result; if (((int64_t)ann->start_sample() <= sample_num) && ((int64_t)ann->end_sample() >= sample_num)) { @@ -335,10 +343,8 @@ QModelIndex AnnotationCollectionModel::update_highlighted_rows(QModelIndex first } while (index != last); } - if (has_highlight || had_highlight_before_) { + if (has_highlight || had_highlight_before_) dataChanged(first, last); - layoutChanged(); - } had_highlight_before_ = has_highlight; @@ -350,6 +356,8 @@ void AnnotationCollectionModel::on_annotation_visibility_changed() if (!hide_hidden_) return; + layoutAboutToBeChanged(); + update_annotations_without_hidden(); if (dataset_)