]> sigrok.org Git - pulseview.git/commitdiff
Tolerate unexpected packets rather than asserting
authorJoel Holdsworth <redacted>
Fri, 15 Mar 2013 19:42:40 +0000 (19:42 +0000)
committerJoel Holdsworth <redacted>
Thu, 21 Mar 2013 22:44:18 +0000 (22:44 +0000)
pv/sigsession.cpp

index a611e7ac7c14159eed9d8e4c569e2a8b79bb9880..5af04b839be314cbc878e664fd6e0ddfb4e5ac41 100644 (file)
@@ -29,6 +29,8 @@
 
 #include <assert.h>
 
+#include <QDebug>
+
 using namespace boost;
 using namespace std;
 
@@ -292,10 +294,15 @@ void SigSession::feed_in_meta(const sr_dev_inst *sdi,
 void SigSession::feed_in_logic(const sr_datafeed_logic &logic)
 {
        lock_guard<mutex> lock(_data_mutex);
-       if (!_cur_logic_snapshot)
+
+       if (!_logic_data)
        {
-               assert(_logic_data);
+               qDebug() << "Unexpected logic packet";
+               return;
+       }
 
+       if (!_cur_logic_snapshot)
+       {
                // Create a new data snapshot
                _cur_logic_snapshot = shared_ptr<data::LogicSnapshot>(
                        new data::LogicSnapshot(logic));
@@ -313,10 +320,15 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic)
 void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
 {
        lock_guard<mutex> lock(_data_mutex);
-       if (!_cur_analog_snapshot)
+
+       if(!_analog_data)
        {
-               assert(_analog_data);
+               qDebug() << "Unexpected analog packet";
+               return; // This analog packet was not expected.
+       }
 
+       if (!_cur_analog_snapshot)
+       {
                // Create a new data snapshot
                _cur_analog_snapshot = shared_ptr<data::AnalogSnapshot>(
                        new data::AnalogSnapshot(analog));