]> sigrok.org Git - pulseview.git/commitdiff
DecodeSignal: Make sure bit IDs are always up-to-date
authorSoeren Apel <redacted>
Tue, 12 Dec 2017 22:31:35 +0000 (23:31 +0100)
committerSoeren Apel <redacted>
Wed, 13 Dec 2017 13:03:59 +0000 (14:03 +0100)
https://www.youtube.com/watch?v=mw6Bd6Hv168 shows what
happens when this isn't done.

pv/data/decodesignal.cpp

index 9b9e6c3c05072795d2751e0f2169c405ba93927d..a7afe44e7408ecf6fac5bdb92f03300493155b46 100644 (file)
@@ -507,7 +507,6 @@ void DecodeSignal::restore_settings(QSettings &settings)
 
                                // Include the newly created decode channels in the channel lists
                                update_channel_list();
-                               commit_decoder_channels();
                                break;
                        }
                }
@@ -544,6 +543,10 @@ void DecodeSignal::restore_settings(QSettings &settings)
                settings.endGroup();
        }
 
+       // Update the internal structures
+       update_channel_list();
+       commit_decoder_channels();
+
        begin_decode();
 }
 
@@ -640,6 +643,12 @@ void DecodeSignal::commit_decoder_channels()
 
                dec->set_channels(channel_list);
        }
+
+       // Channel bit IDs must be in sync with the channel's apperance in channels_
+       int id = 0;
+       for (data::DecodeChannel &ch : channels_)
+               if (ch.assigned_signal)
+                       ch.bit_id = id++;
 }
 
 void DecodeSignal::mux_logic_samples(const int64_t start, const int64_t end)
@@ -655,11 +664,8 @@ void DecodeSignal::mux_logic_samples(const int64_t start, const int64_t end)
        vector<uint8_t> signal_in_bytepos;
        vector<uint8_t> signal_in_bitpos;
 
-       int id = 0;
        for (data::DecodeChannel &ch : channels_)
                if (ch.assigned_signal) {
-                       ch.bit_id = id++;
-
                        const shared_ptr<Logic> logic_data = ch.assigned_signal->logic_data();
                        const shared_ptr<LogicSegment> segment = logic_data->logic_segments().front();
                        segments.push_back(segment);