- auto row_iter = ds->segments_.at(ds->current_segment_id_).annotation_rows.end();
-
- // Try finding a better row match than the default by looking up the sub-row of this class
- const auto format = pda->ann_class;
- const auto r = ds->class_rows_.find(make_pair(decc, format));
- if (r != ds->class_rows_.end())
- row_iter = ds->segments_.at(ds->current_segment_id_).annotation_rows.find((*r).second);
- else {
- // Failing that, use the decoder as a key
- for (const shared_ptr<decode::Decoder>& dec : ds->decoder_stack())
- if (dec->decoder() == decc)
- row_iter = ds->segments_.at(ds->current_segment_id_).annotation_rows.find(Row(0, dec.get()));
- }
-
- if (row_iter == ds->segments_.at(ds->current_segment_id_).annotation_rows.end()) {
- qDebug() << "Unexpected annotation: decoder = " << decc <<
- ", format = " << format;
- assert(false);
+ Decoder* dec = ds->get_decoder_by_instance(srd_dec);
+ assert(dec);
+
+ AnnotationClass* ann_class = dec->get_ann_class_by_id(pda->ann_class);
+ if (!ann_class) {
+ qWarning() << "Decoder" << ds->display_name() << "wanted to add annotation" <<
+ "with class ID" << pda->ann_class << "but there are only" <<
+ dec->ann_classes().size() << "known classes";