X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecode%2Frow.cpp;h=6212c92195bb888838348122f14624d0e83f2edc;hp=d127a2eadaf3045180452a148777f33cb30c9f08;hb=eb31c238473de0784ec57b9782e11082613a7a7a;hpb=9e5ccb72d09fe70cda63445aaf3957568567abf5 diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp index d127a2ea..6212c921 100644 --- a/pv/data/decode/row.cpp +++ b/pv/data/decode/row.cpp @@ -18,6 +18,7 @@ */ #include +#include #include "decoder.hpp" #include "row.hpp" @@ -149,17 +150,31 @@ const QColor Row::color() const const QColor Row::get_class_color(uint32_t ann_class_id) const { - return ann_class_color_.at(ann_class_id); + try { + return ann_class_color_.at(ann_class_id); + } catch (std::out_of_range &e) { + qWarning() << "Warning: annotation type" << decoder_->get_ann_class_by_id(ann_class_id)->name + << "(" << ann_class_id << ")" << "not assigned to any annotation row!"; + return QColor(20, 20, 20); + } } const QColor Row::get_bright_class_color(uint32_t ann_class_id) const { - return ann_bright_class_color_.at(ann_class_id); + try { + return ann_bright_class_color_.at(ann_class_id); + } catch (std::out_of_range &e) { + return QColor(20, 20, 20); + } } const QColor Row::get_dark_class_color(uint32_t ann_class_id) const { - return ann_dark_class_color_.at(ann_class_id); + try { + return ann_dark_class_color_.at(ann_class_id); + } catch (std::out_of_range &e) { + return QColor(20, 20, 20); + } } bool Row::has_hidden_classes() const