]> sigrok.org Git - pulseview.git/commitdiff
Fix #981 by adding non-device signals upon view creation
authorSoeren Apel <redacted>
Wed, 14 Jun 2017 19:53:58 +0000 (21:53 +0200)
committerUwe Hermann <redacted>
Wed, 5 Jul 2017 22:37:08 +0000 (00:37 +0200)
pv/session.cpp

index f96fc869ecad613816196072409c4d1458e198ad..b022bd02c0c02681bd576a06fff085b89f27e0c8 100644 (file)
@@ -597,7 +597,44 @@ void Session::register_view(shared_ptr<views::ViewBase> view)
 
        views_.push_back(view);
 
+       // Add all device signals
        update_signals();
+
+       // Add all other signals
+       unordered_set< shared_ptr<data::SignalBase> > view_signalbases =
+               view->signalbases();
+
+       views::trace::View *trace_view =
+               qobject_cast<views::trace::View*>(view.get());
+
+       if (trace_view) {
+               for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+                       const int sb_exists = count_if(
+                               view_signalbases.cbegin(), view_signalbases.cend(),
+                               [&](const shared_ptr<data::SignalBase> &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<data::DecodeSignal>(signalbase));
+#endif
+                                       break;
+                               case data::SignalBase::MathChannel:
+                                       // TBD
+                                       break;
+                               }
+               }
+       }
+
+       signals_changed();
 }
 
 void Session::deregister_view(shared_ptr<views::ViewBase> view)