From: Joel Holdsworth Date: Sat, 8 Feb 2014 16:42:18 +0000 (+0000) Subject: Do not attempt to decode when required probes have not been specified X-Git-Tag: pulseview-0.2.0~84 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a2d4b5512a87a5d60e09fd69b6eec34332c714de;p=pulseview.git Do not attempt to decode when required probes have not been specified This fixes 204 --- diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 0404227e..3767e485 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -84,6 +84,18 @@ void Decoder::set_option(const char *id, GVariant *value) _options[id] = value; } +bool Decoder::have_required_probes() const +{ + for (GSList *p = _decoder->probes; p; p = p->next) { + const srd_probe *const probe = (const srd_probe*)p->data; + assert(probe); + if (_probes.find(probe) == _probes.end()) + return false; + } + + return true; +} + srd_decoder_inst* Decoder::create_decoder_inst( srd_session *const session) const { diff --git a/pv/data/decode/decoder.h b/pv/data/decode/decoder.h index f96ba2b6..08795585 100644 --- a/pv/data/decode/decoder.h +++ b/pv/data/decode/decoder.h @@ -62,6 +62,8 @@ public: void set_option(const char *id, GVariant *value); + bool have_required_probes() const; + srd_decoder_inst* create_decoder_inst( srd_session *const session) const; diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 073dcd52..74ad7d36 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -246,11 +246,17 @@ void DecoderStack::decode_proc(shared_ptr data) assert(data); + // Check we have a snapshot of data const deque< shared_ptr > &snapshots = data->get_snapshots(); if (snapshots.empty()) return; + // Check that all decoders have the required probes + BOOST_FOREACH(const shared_ptr &dec, _stack) + if (!dec->have_required_probes()) + return; + const shared_ptr &snapshot = snapshots.front(); const int64_t sample_count = snapshot->get_sample_count();