From: Soeren Apel Date: Wed, 14 Jun 2017 19:53:58 +0000 (+0200) Subject: Fix #981 by adding non-device signals upon view creation X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f5a5b019c5679dbe6b4bc6f956c3820f47869bc1;p=pulseview.git Fix #981 by adding non-device signals upon view creation --- diff --git a/pv/session.cpp b/pv/session.cpp index f96fc869..b022bd02 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -597,7 +597,44 @@ void Session::register_view(shared_ptr view) views_.push_back(view); + // Add all device signals update_signals(); + + // Add all other signals + unordered_set< shared_ptr > view_signalbases = + view->signalbases(); + + views::trace::View *trace_view = + qobject_cast(view.get()); + + if (trace_view) { + for (shared_ptr signalbase : signalbases_) { + const int sb_exists = count_if( + view_signalbases.cbegin(), view_signalbases.cend(), + [&](const shared_ptr &sb) { + return sb == signalbase; + }); + // Add the signal to the view as it doesn't have it yet + if (!sb_exists) + switch (signalbase->type()) { + case data::SignalBase::AnalogChannel: + case data::SignalBase::LogicChannel: + case data::SignalBase::A2LChannel: + break; + case data::SignalBase::DecodeChannel: +#ifdef ENABLE_DECODE + trace_view->add_decode_signal( + dynamic_pointer_cast(signalbase)); +#endif + break; + case data::SignalBase::MathChannel: + // TBD + break; + } + } + } + + signals_changed(); } void Session::deregister_view(shared_ptr view)