From: Soeren Apel Date: Sun, 10 Mar 2019 09:43:22 +0000 (+0100) Subject: DecodeSignal: Use name of last stacked PD unless the name was changed X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=commitdiff_plain;h=b9591f3a680dd35b7af2fb482a136b1bd494c6e4;hp=97378470ded88af84edaa0f1063d10d834475665 DecodeSignal: Use name of last stacked PD unless the name was changed --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 68b17a6..4a802c3 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -78,14 +78,19 @@ const vector< shared_ptr >& DecodeSignal::decoder_stack() const void DecodeSignal::stack_decoder(const srd_decoder *decoder) { assert(decoder); - const shared_ptr dec = make_shared(decoder); - stack_.push_back(dec); + // Set name if this decoder is the first in the list or the name is unchanged + const srd_decoder* prev_dec = + stack_.empty() ? nullptr : stack_.back()->decoder(); + const QString prev_dec_name = + prev_dec ? QString::fromUtf8(prev_dec->name) : QString(); - // Set name if this decoder is the first in the list - if (stack_.size() == 1) + if ((stack_.empty()) || ((stack_.size() > 0) && (name() == prev_dec_name))) set_name(QString::fromUtf8(decoder->name)); + const shared_ptr dec = make_shared(decoder); + stack_.push_back(dec); + // Include the newly created decode channels in the channel lists update_channel_list();