From: Soeren Apel Date: Fri, 17 Apr 2020 17:44:16 +0000 (+0200) Subject: TabularDecView: Increase robustness X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=02c87df7336eb81b770457b4153cf2dc649ffdab TabularDecView: Increase robustness --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index a4888175..6f0e0fa7 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -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 lock(ds->output_mutex_); // Get the decoder and the annotation data diff --git a/pv/views/tabular_decoder/view.cpp b/pv/views/tabular_decoder/view.cpp index 069e55a0..4f4c6238 100644 --- a/pv/views/tabular_decoder/view.cpp +++ b/pv/views/tabular_decoder/view.cpp @@ -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); diff --git a/pv/views/tabular_decoder/view.hpp b/pv/views/tabular_decoder/view.hpp index b19ba614..8e1dfa41 100644 --- a/pv/views/tabular_decoder/view.hpp +++ b/pv/views/tabular_decoder/view.hpp @@ -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);