X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;fp=pv%2Fdata%2Fdecodesignal.cpp;h=77784de07f84dcdce9431ef03fc634de56aed02e;hp=6f0e0fa7c50594632bf3305d3a01a56179f21f43;hb=88a2597864920ecdbe66cf0cd4b8172bdabb2263;hpb=ae30ff422a495a6b1a4ad2893566628863ea222b diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 6f0e0fa7..77784de0 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -1460,6 +1460,29 @@ void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signa deque& all_annotations = ds->segments_[ds->current_segment_id_].all_annotations; all_annotations.emplace_back(ann); + + // When emplace_annotation() inserts instead of appends an annotation, + // the pointers in all_annotations that follow the inserted annotation and + // point to annotations for this row are off by one and must be updated + if (&(row_data.annotations().back()) != ann) { + // Search backwards until we find the annotation we just added + auto row_it = row_data.annotations().end(); + auto all_it = all_annotations.end(); + do { + all_it--; + if ((*all_it)->row_data() == &row_data) + row_it--; + } while (&(*row_it) != ann); + + // Update the annotation addresses for this row's annotations until the end + do { + if ((*all_it)->row_data() == &row_data) { + *all_it = &(*row_it); + row_it++; + } + all_it++; + } while (all_it != all_annotations.end()); + } } void DecodeSignal::binary_callback(srd_proto_data *pdata, void *decode_signal)