]> sigrok.org Git - pulseview.git/commitdiff
Fix #1596 by fixing some race conditions
authorSoeren Apel <redacted>
Sat, 5 Sep 2020 20:04:01 +0000 (22:04 +0200)
committerSoeren Apel <redacted>
Sat, 5 Sep 2020 20:04:55 +0000 (22:04 +0200)
1) Let DecodeSignal::reset_decode() handle the srd session
2) Check for decode_interrupt_ before triggering signal

pv/data/decodesignal.cpp

index 12077a96f5b766c14c5839196195585e0e745ca4..b9a1fabc74917fc2cc8791ed9ae7abe8ff04b38b 100644 (file)
@@ -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<shared_ptr<const LogicSegment> > segments;
        vector<const uint8_t*> signal_data;
        vector<uint8_t> 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> logic_data = ch.assigned_signal->logic_data();
 
                        shared_ptr<const LogicSegment> 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<LogicSegment> 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()