X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;h=831c8e7f90c41964dee9b2a496705ccd170db0ce;hb=d5e790204dcc9a6aa8626294aa505634c179261f;hp=a66e69d967b9fe7c54363da06e0f5703df6798e2;hpb=6a26fc4417798ab21654197e105e707a14d462f0;p=pulseview.git diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index a66e69d9..831c8e7f 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -41,11 +41,8 @@ using std::min; using std::out_of_range; using std::shared_ptr; using std::unique_lock; -using pv::data::decode::Annotation; using pv::data::decode::AnnotationClass; using pv::data::decode::DecodeChannel; -using pv::data::decode::Decoder; -using pv::data::decode::Row; namespace pv { namespace data { @@ -136,8 +133,8 @@ bool DecodeSignal::toggle_decoder_visibility(int index) // Toggle decoder visibility bool state = false; if (dec) { - state = !dec->shown(); - dec->show(state); + state = !dec->visible(); + dec->set_visible(state); } return state; @@ -437,7 +434,7 @@ vector DecodeSignal::get_rows(bool visible_only) for (const shared_ptr& dec : stack_) { assert(dec); - if (visible_only && !dec->shown()) + if (visible_only && !dec->visible()) continue; for (Row* row : dec->get_rows()) @@ -453,7 +450,7 @@ vector DecodeSignal::get_rows(bool visible_only) const for (const shared_ptr& dec : stack_) { assert(dec); - if (visible_only && !dec->shown()) + if (visible_only && !dec->visible()) continue; for (const Row* row : dec->get_rows()) @@ -474,17 +471,15 @@ uint64_t DecodeSignal::get_annotation_count(const Row* row, uint32_t segment_id) auto row_it = segment->annotation_rows.find(row); const RowData* rd; - if (row_it == segment->annotation_rows.end()) { - // FIXME Use the fallback row, but how? - assert(false); + if (row_it == segment->annotation_rows.end()) return 0; - } else + else rd = &(row_it->second); return rd->get_annotation_count(); } -void DecodeSignal::get_annotation_subset(vector &dest, +void DecodeSignal::get_annotation_subset(vector &dest, const Row* row, uint32_t segment_id, uint64_t start_sample, uint64_t end_sample) const { @@ -498,29 +493,27 @@ void DecodeSignal::get_annotation_subset(vector &dest, auto row_it = segment->annotation_rows.find(row); const RowData* rd; - if (row_it == segment->annotation_rows.end()) { - // FIXME Use the fallback row, but how? - assert(false); + if (row_it == segment->annotation_rows.end()) return; - } else + else rd = &(row_it->second); rd->get_annotation_subset(dest, start_sample, end_sample); } -void DecodeSignal::get_annotation_subset(vector &dest, +void DecodeSignal::get_annotation_subset(vector &dest, uint32_t segment_id, uint64_t start_sample, uint64_t end_sample) const { // Use forward_lists for faster merging - forward_list *all_ann_list = new forward_list(); + forward_list *all_ann_list = new forward_list(); vector rows = get_rows(); for (const Row* row : rows) { - vector *ann_vector = new vector(); + vector *ann_vector = new vector(); get_annotation_subset(*ann_vector, row, segment_id, start_sample, end_sample); - forward_list *ann_list = - new forward_list(ann_vector->begin(), ann_vector->end()); + forward_list *ann_list = + new forward_list(ann_vector->begin(), ann_vector->end()); delete ann_vector; all_ann_list->merge(*ann_list); @@ -679,7 +672,7 @@ void DecodeSignal::save_settings(QSettings &settings) const settings.beginGroup("decoder" + QString::number(decoder_idx++)); settings.setValue("id", decoder->get_srd_decoder()->id); - settings.setValue("shown", decoder->shown()); + settings.setValue("visible", decoder->visible()); // Save decoder options const map& options = decoder->options(); @@ -747,7 +740,7 @@ void DecodeSignal::restore_settings(QSettings &settings) shared_ptr decoder = make_shared(dec); stack_.push_back(decoder); - decoder->show(settings.value("shown", true).toBool()); + decoder->set_visible(settings.value("visible", true).toBool()); // Restore decoder options that differ from their default int options = settings.value("options").toInt(); @@ -1411,7 +1404,12 @@ void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signa assert(dec); AnnotationClass* ann_class = dec->get_ann_class_by_id(pda->ann_class); - assert(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"; + return; + } const Row* row = ann_class->row;