]> sigrok.org Git - pulseview.git/blobdiff - pv/session.cpp
Session: Make sure we don't try to add a non-existant decoder
[pulseview.git] / pv / session.cpp
index f5f1e4974b6ea155dcdb923924a05c0fef4077c3..0056e460b81ad92b2ef075bc43014914bd16ba3e 100644 (file)
@@ -620,6 +620,9 @@ const unordered_set< shared_ptr<data::SignalBase> > Session::signalbases() const
 #ifdef ENABLE_DECODE
 bool Session::add_decoder(srd_decoder *const dec)
 {
+       if (!dec)
+               return false;
+
        map<const srd_channel*, shared_ptr<data::SignalBase> > channels;
        shared_ptr<data::DecoderStack> decoder_stack;
 
@@ -962,7 +965,7 @@ void Session::feed_in_logic(shared_ptr<Logic> logic)
 
                // Create a new data segment
                cur_logic_segment_ = make_shared<data::LogicSegment>(
-                       *logic_data_, logic, cur_samplerate_);
+                       *logic_data_, logic->unit_size(), cur_samplerate_);
                logic_data_->push_segment(cur_logic_segment_);
 
                // @todo Putting this here means that only listeners querying
@@ -970,11 +973,10 @@ void Session::feed_in_logic(shared_ptr<Logic> logic)
                // frame_began is DecoderStack, but in future we need to signal
                // this after both analog and logic sweeps have begun.
                frame_began();
-       } else {
-               // Append to the existing data segment
-               cur_logic_segment_->append_payload(logic);
        }
 
+       cur_logic_segment_->append_payload(logic);
+
        data_received();
 }