From: Soeren Apel Date: Wed, 5 Jul 2017 16:16:18 +0000 (+0200) Subject: DecodeSignal: Auto-assign only the channels of newly added decoders X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=762ab7a4b20928a784b2b3400ce748d901e32d2d;p=pulseview.git DecodeSignal: Auto-assign only the channels of newly added decoders Before, the channels of all decoders in the stack were auto-assigned, potentially messing up the configuration the user chose. --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 5acf9eec..a57a9a1a 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -79,7 +79,9 @@ const vector< shared_ptr >& DecodeSignal::decoder_stack() const void DecodeSignal::stack_decoder(const srd_decoder *decoder) { assert(decoder); - stack_.push_back(make_shared(decoder)); + const shared_ptr dec = make_shared(decoder); + + stack_.push_back(dec); // Set name if this decoder is the first in the list if (stack_.size() == 1) @@ -88,7 +90,7 @@ void DecodeSignal::stack_decoder(const srd_decoder *decoder) // Include the newly created decode channels in the channel lists update_channel_list(); - auto_assign_signals(); + auto_assign_signals(dec); commit_decoder_channels(); begin_decode(); } @@ -263,12 +265,16 @@ const vector DecodeSignal::get_channels() const return channels_; } -void DecodeSignal::auto_assign_signals() +void DecodeSignal::auto_assign_signals(const shared_ptr dec) { bool new_assignment = false; // Try to auto-select channels that don't have signals assigned yet for (data::DecodeChannel &ch : channels_) { + // If a decoder is given, auto-assign only its channels + if (dec && (ch.decoder_ != dec)) + continue; + if (ch.assigned_signal) continue; diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index d50aace9..3d90f7f7 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -96,7 +96,7 @@ public: QString error_message() const; const vector get_channels() const; - void auto_assign_signals(); + void auto_assign_signals(const shared_ptr dec); void assign_signal(const uint16_t channel_id, const SignalBase *signal); int get_assigned_signal_count() const;