]> sigrok.org Git - pulseview.git/blobdiff - pv/views/tabular_decoder/model.cpp
TabularDecView: Prevent a race condition
[pulseview.git] / pv / views / tabular_decoder / model.cpp
index 110cfd62b98d2280acea700a1ce130a50eb5f5a3..d85bf6aac7721d38106292254b811c30896426e7 100644 (file)
@@ -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();
 }
@@ -324,9 +327,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<const Annotation*>(index.internalPointer());
-                       assert(ann);
+                       const Annotation* ann = static_cast<const Annotation*>(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)) {