]> sigrok.org Git - pulseview.git/blobdiff - pv/session.cpp
Session: Don't process packets without sample data
[pulseview.git] / pv / session.cpp
index 008ee6a282cc3ba326abe6b106a503576d7d753c..cbf24e235acc274c478c79481bfc5b446c80939f 100644 (file)
@@ -299,8 +299,8 @@ void Session::restore_settings(QSettings &settings)
                                filename.toStdString());
                        set_device(device);
 
-                       // TODO Perform error handling
-                       start_capture([](QString infoMessage) { (void)infoMessage; });
+                       start_capture([](QString infoMessage) {
+                               qDebug().noquote() << "Session error:" << infoMessage; });
 
                        set_name(QFileInfo(filename).fileName());
                }
@@ -953,10 +953,8 @@ void Session::sample_thread_proc(function<void (const QString)> error_handler)
        set_capture_state(Stopped);
 
        // Confirm that SR_DF_END was received
-       if (cur_logic_segment_) {
-               qDebug("SR_DF_END was not received.");
-               assert(false);
-       }
+       if (cur_logic_segment_)
+               qDebug() << "WARNING: SR_DF_END was not received.";
 
        // Optimize memory usage
        free_unused_memory();
@@ -1132,6 +1130,11 @@ void Session::feed_in_frame_end()
 
 void Session::feed_in_logic(shared_ptr<Logic> logic)
 {
+       if (logic->data_length() == 0) {
+               qDebug() << "WARNING: Received logic packet with 0 samples.";
+               return;
+       }
+
        if (!cur_samplerate_)
                cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);
 
@@ -1164,6 +1167,11 @@ void Session::feed_in_logic(shared_ptr<Logic> logic)
 
 void Session::feed_in_analog(shared_ptr<Analog> analog)
 {
+       if (analog->num_samples() == 0) {
+               qDebug() << "WARNING: Received analog packet with 0 samples.";
+               return;
+       }
+
        if (!cur_samplerate_)
                cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);
 
@@ -1282,6 +1290,15 @@ void Session::data_feed_in(shared_ptr<sigrok::Device> device,
                // devices use frames, and for those devices, we need to do it here.
                {
                        lock_guard<recursive_mutex> lock(data_mutex_);
+
+                       if (cur_logic_segment_)
+                               cur_logic_segment_->set_complete();
+
+                       for (auto entry : cur_analog_segments_) {
+                               shared_ptr<data::AnalogSegment> segment = entry.second;
+                               segment->set_complete();
+                       }
+
                        cur_logic_segment_.reset();
                        cur_analog_segments_.clear();
                }