]> sigrok.org Git - pulseview.git/commitdiff
TabularDecView: Prevent a race condition
authorSoeren Apel <redacted>
Fri, 3 Jul 2020 13:43:51 +0000 (15:43 +0200)
committerSoeren Apel <redacted>
Fri, 3 Jul 2020 13:43:51 +0000 (15:43 +0200)
When it occurs, section is -1 and we'd throw an exception.
Catch the case instead and simply ignore it.

pv/views/tabular_decoder/model.cpp

index b87bf05869ef1f118ad69853ff3899ec4e1d097a..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
 {
 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))
        if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole))
-               return header_data_.at(section);
+               return header_data_[section];
 
        return QVariant();
 }
 
        return QVariant();
 }