X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fdecode%2Fannotation.cpp;fp=pv%2Fdata%2Fdecode%2Fannotation.cpp;h=e32dcc9fdc7f0b529dde1b90666b21abbe64e69e;hb=462941e2626cef9855e810abdb0458e99ee1c5f1;hp=55caa2d7adbfb9810260811ef5b6c0b1372ef2f3;hpb=ef8d23e798d2b4799c4bcd13a85a1d4b7d1d897b;p=pulseview.git diff --git a/pv/data/decode/annotation.cpp b/pv/data/decode/annotation.cpp index 55caa2d7..e32dcc9f 100644 --- a/pv/data/decode/annotation.cpp +++ b/pv/data/decode/annotation.cpp @@ -42,15 +42,51 @@ Annotation::Annotation(const srd_proto_data *const pdata, const Row *row) : (const srd_proto_data_annotation*)pdata->data; assert(pda); - ann_class_ = (Class)(pda->ann_class); + ann_class_id_ = (Class)(pda->ann_class); + + annotations_ = new vector(); const char *const *annotations = (char**)pda->ann_text; while (*annotations) { - annotations_.push_back(QString::fromUtf8(*annotations)); + annotations_->push_back(QString::fromUtf8(*annotations)); annotations++; } - annotations_.shrink_to_fit(); + annotations_->shrink_to_fit(); +} + +Annotation::Annotation(Annotation&& a) : + start_sample_(a.start_sample_), + end_sample_(a.end_sample_), + annotations_(a.annotations_), + row_(a.row_), + ann_class_id_(a.ann_class_id_) +{ + a.annotations_ = nullptr; +} + +Annotation& Annotation::operator=(Annotation&& a) +{ + if (&a != this) { + if (annotations_) + delete annotations_; + + start_sample_ = a.start_sample_; + end_sample_ = a.end_sample_; + annotations_ = a.annotations_; + row_ = a.row_; + ann_class_id_ = a.ann_class_id_; + + a.annotations_ = nullptr; + } + + return *this; +} + +Annotation::~Annotation() +{ + if (annotations_) + delete annotations_; } uint64_t Annotation::start_sample() const @@ -63,12 +99,12 @@ uint64_t Annotation::end_sample() const return end_sample_; } -Annotation::Class Annotation::ann_class() const +Annotation::Class Annotation::ann_class_id() const { - return ann_class_; + return ann_class_id_; } -const vector& Annotation::annotations() const +const vector* Annotation::annotations() const { return annotations_; }