X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;h=9decbe302fe5892864b9c083ad36e28d37d0f3ff;hb=30cdef99af65a04ee8c55ab816044c32f7e955ad;hp=a3525922943a878b5d051fbdb724eb44a9f2100a;hpb=04b0467582d8dfa989bb38fe18bfb1be20cea456;p=pulseview.git diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index a3525922..9decbe30 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -370,7 +370,7 @@ void DecodeSignal::update_output_signals() dec->logic_output_channels(); // All signals of a decoder share the same LogicSegment, so it's - // sufficient to check for the first channel only + // sufficient to check for only the first channel const decode::DecoderLogicOutputChannel& first_ch = logic_channels[0]; bool ch_exists = false; @@ -380,6 +380,7 @@ void DecodeSignal::update_output_signals() if (!ch_exists) { shared_ptr logic_data = make_shared(logic_channels.size()); + logic_data->set_samplerate(first_ch.samplerate); output_logic_[dec->get_srd_decoder()] = logic_data; shared_ptr logic_segment = make_shared( @@ -1723,9 +1724,19 @@ void DecodeSignal::logic_output_callback(srd_proto_data *pdata, void *decode_sig assert(pdl); shared_ptr output_logic = ds->output_logic_.at(decc); - shared_ptr last_segment = - dynamic_pointer_cast(output_logic->segments().back()); - assert(last_segment); + + vector< shared_ptr > segments = output_logic->segments(); + + shared_ptr last_segment; + + if (!segments.empty()) + last_segment = dynamic_pointer_cast(segments.back()); + else { + // Happens when the data was cleared - all segments are gone then + last_segment = make_shared( + *output_logic, 0, (output_logic->num_channels() + 7) / 8, output_logic->get_samplerate()); + output_logic->push_segment(last_segment); + } last_segment->append_subsignal_payload(pdl->logic_class, (void*)pdl->data, pdl->size);