]> sigrok.org Git - pulseview.git/commitdiff
TabularDecView: Increase robustness
authorSoeren Apel <redacted>
Fri, 17 Apr 2020 17:44:16 +0000 (19:44 +0200)
committerUwe Hermann <redacted>
Sun, 3 May 2020 15:20:55 +0000 (17:20 +0200)
pv/data/decodesignal.cpp
pv/views/tabular_decoder/view.cpp
pv/views/tabular_decoder/view.hpp

index a488817525ec9f64a6e08400e3812a7e07ef28e5..6f0e0fa7c50594632bf3305d3a01a56179f21f43 100644 (file)
@@ -1420,6 +1420,9 @@ void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signa
        if (ds->decode_interrupt_)
                return;
 
+       if (ds->segments_.empty())
+               return;
+
        lock_guard<mutex> lock(ds->output_mutex_);
 
        // Get the decoder and the annotation data
index 069e55a02e8189a945d49ccc96a91e278b2c0ca9..4f4c6238b02927e6d699417b4ea6184a3b196d1a 100644 (file)
@@ -273,8 +273,10 @@ void View::save_data() const
 
 void View::on_selected_decoder_changed(int index)
 {
-       if (signal_)
+       if (signal_) {
                disconnect(signal_, SIGNAL(new_annotations()));
+               disconnect(signal_, SIGNAL(decode_reset()));
+       }
 
        reset_data();
 
@@ -286,8 +288,10 @@ void View::on_selected_decoder_changed(int index)
                        if (decoder_ == dec.get())
                                signal_ = ds.get();
 
-       if (signal_)
+       if (signal_) {
                connect(signal_, SIGNAL(new_annotations()), this, SLOT(on_new_annotations()));
+               connect(signal_, SIGNAL(decode_reset()), this, SLOT(on_decoder_reset()));
+       }
 
        update_data();
 }
@@ -319,6 +323,13 @@ void View::on_new_annotations()
                delayed_view_updater_.start();
 }
 
+void View::on_decoder_reset()
+{
+       // Invalidate the model's data connection immediately - otherwise we
+       // will use a stale pointer in model_->index() when called from the table view
+       model_->set_signal_and_segment(signal_, current_segment_);
+}
+
 void View::on_decoder_stacked(void* decoder)
 {
        Decoder* d = static_cast<Decoder*>(decoder);
index b19ba61450fbe59248f9a6950fc55794585ef324..8e1dfa4179432ce96891e4ccce2e929ceaa89178 100644 (file)
@@ -108,6 +108,7 @@ private Q_SLOTS:
        void on_signal_name_changed(const QString &name);
        void on_new_annotations();
 
+       void on_decoder_reset();
        void on_decoder_stacked(void* decoder);
        void on_decoder_removed(void* decoder);