]> sigrok.org Git - pulseview.git/commitdiff
DecodeSignal: Auto-assign only the channels of newly added decoders
authorSoeren Apel <redacted>
Wed, 5 Jul 2017 16:16:18 +0000 (18:16 +0200)
committerUwe Hermann <redacted>
Wed, 5 Jul 2017 22:37:09 +0000 (00:37 +0200)
Before, the channels of all decoders in the stack were auto-assigned,
potentially messing up the configuration the user chose.

pv/data/decodesignal.cpp
pv/data/decodesignal.hpp

index 5acf9eec634380533a2cb1c0bfeceb767cec6f7b..a57a9a1a9624556d5658dc3d6d3877f160194095 100644 (file)
@@ -79,7 +79,9 @@ const vector< shared_ptr<Decoder> >& DecodeSignal::decoder_stack() const
 void DecodeSignal::stack_decoder(const srd_decoder *decoder)
 {
        assert(decoder);
-       stack_.push_back(make_shared<decode::Decoder>(decoder));
+       const shared_ptr<Decoder> dec = make_shared<decode::Decoder>(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<data::DecodeChannel> DecodeSignal::get_channels() const
        return channels_;
 }
 
-void DecodeSignal::auto_assign_signals()
+void DecodeSignal::auto_assign_signals(const shared_ptr<Decoder> 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;
 
index d50aace9c2dc841fe62c5b820dcd9aa8a4bd22e0..3d90f7f7de648e861d117fc24e8b1200b44fe952 100644 (file)
@@ -96,7 +96,7 @@ public:
        QString error_message() const;
 
        const vector<data::DecodeChannel> get_channels() const;
-       void auto_assign_signals();
+       void auto_assign_signals(const shared_ptr<pv::data::decode::Decoder> dec);
        void assign_signal(const uint16_t channel_id, const SignalBase *signal);
        int get_assigned_signal_count() const;