From: Soeren Apel Date: Sun, 8 Apr 2018 21:03:33 +0000 (+0200) Subject: Channels: Let "Enable all changing" also check for sample data X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=d13d95b3eaee713cc4eabbc0682ca545b4c31800 Channels: Let "Enable all changing" also check for sample data --- diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index 2972d404..5f6dc398 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -238,6 +238,33 @@ bool SignalBase::segment_is_complete(uint32_t segment_id) const return result; } +bool SignalBase::has_samples() const +{ + bool result = false; + + if (channel_type_ == AnalogChannel) + { + shared_ptr data = dynamic_pointer_cast(data_); + if (data) { + auto segments = data->analog_segments(); + if ((segments.size() > 0) && (segments.front()->get_sample_count() > 0)) + result = true; + } + } + + if (channel_type_ == LogicChannel) + { + shared_ptr data = dynamic_pointer_cast(data_); + if (data) { + auto segments = data->logic_segments(); + if ((segments.size() > 0) && (segments.front()->get_sample_count() > 0)) + result = true; + } + } + + return result; +} + SignalBase::ConversionType SignalBase::get_conversion_type() const { return conversion_type_; diff --git a/pv/data/signalbase.hpp b/pv/data/signalbase.hpp index efe4a54a..3356af5b 100644 --- a/pv/data/signalbase.hpp +++ b/pv/data/signalbase.hpp @@ -187,6 +187,11 @@ public: */ bool segment_is_complete(uint32_t segment_id) const; + /** + * Determines whether this signal has any sample data at all. + */ + bool has_samples() const; + /** * Queries the kind of conversion performed on this channel. */ diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index a24c2651..fdb97728 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -311,6 +311,10 @@ void Channels::enable_all_changing_channels() { set_all_channels_conditionally([](const shared_ptr signal) { + // Never enable channels without sample data + if (!signal->has_samples()) + return false; + // Non-logic channels are considered to always have a signal if (signal->type() != SignalBase::LogicChannel) return true;