From: Soeren Apel Date: Tue, 12 Dec 2017 22:31:35 +0000 (+0100) Subject: DecodeSignal: Make sure bit IDs are always up-to-date X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;ds=sidebyside;h=aa71890d74df0a7d449138dd9dd3bd907740df51;hp=a00f8221dce2af1e88d5eefc7b3689c377f4b72c;p=pulseview.git DecodeSignal: Make sure bit IDs are always up-to-date https://www.youtube.com/watch?v=mw6Bd6Hv168 shows what happens when this isn't done. --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 9b9e6c3..a7afe44 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -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 signal_in_bytepos; vector signal_in_bitpos; - int id = 0; for (data::DecodeChannel &ch : channels_) if (ch.assigned_signal) { - ch.bit_id = id++; - const shared_ptr logic_data = ch.assigned_signal->logic_data(); const shared_ptr segment = logic_data->logic_segments().front(); segments.push_back(segment);