From: Soeren Apel Date: Sat, 5 Sep 2020 20:04:01 +0000 (+0200) Subject: Fix #1596 by fixing some race conditions X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f5a26d5ea895f820c980326be6cee1d46cb958e3;p=pulseview.git Fix #1596 by fixing some race conditions 1) Let DecodeSignal::reset_decode() handle the srd session 2) Check for decode_interrupt_ before triggering signal --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 12077a96..b9a1fabc 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -1009,7 +1009,6 @@ void DecodeSignal::mux_logic_samples(uint32_t segment_id, const int64_t start, c return; // Fetch the channel segments and their data - bool segment_missing = false; vector > segments; vector signal_data; vector signal_in_bytepos; @@ -1020,19 +1019,17 @@ void DecodeSignal::mux_logic_samples(uint32_t segment_id, const int64_t start, c const shared_ptr logic_data = ch.assigned_signal->logic_data(); shared_ptr segment; - try { + if (segment_id < logic_data->logic_segments().size()) { segment = logic_data->logic_segments().at(segment_id)->get_shared_ptr(); - } catch (out_of_range&) { + } else { qDebug() << "Muxer error for" << name() << ":" << ch.assigned_signal->name() \ << "has no logic segment" << segment_id; logic_mux_interrupt_ = true; return; } - if (!segment) { - segment_missing = true; - break; - } + if (!segment) + return; segments.push_back(segment); @@ -1045,9 +1042,6 @@ void DecodeSignal::mux_logic_samples(uint32_t segment_id, const int64_t start, c signal_in_bitpos.push_back(bitpos % 8); } - if (segment_missing) - return; - shared_ptr output_segment; try { output_segment = logic_mux_data_->logic_segments().at(segment_id); @@ -1302,7 +1296,8 @@ void DecodeSignal::decode_proc() terminate_srd_session(); } else { // All segments have been processed - decode_finished(); + if (!decode_interrupt_) + decode_finished(); } } else { // Wait for more input data @@ -1311,11 +1306,6 @@ void DecodeSignal::decode_proc() } } } while (!decode_interrupt_); - - // Potentially reap decoders when the application no longer is - // interested in their (pending) results. - if (decode_interrupt_) - terminate_srd_session(); } void DecodeSignal::start_srd_session()