Added assertions to confirm that the session was terminated cleanly
[pulseview.git] / pv / sigsession.cpp
index 131f057de5d881e72d442418dff4952ebef74a27..4fe51dd57131682ae11c31f45eb85f6aee4de461 100644 (file)
@@ -59,13 +59,12 @@ SigSession::~SigSession()
        _session = NULL;
 }
 
-struct sr_dev_inst* SigSession::get_device() const
-{
-       return _sdi;
-}
-
 void SigSession::set_device(struct sr_dev_inst *sdi)
 {
+       if (_sdi)
+               sr_dev_close(_sdi);
+       if (sdi)
+               sr_dev_open(sdi);
        _sdi = sdi;
 }
 
@@ -167,6 +166,10 @@ void SigSession::load_thread_proc(const string name,
        sr_session_destroy();
 
        set_capture_state(Stopped);
+
+       // Confirm that SR_DF_END was received
+       assert(!_cur_logic_snapshot);
+       assert(!_cur_analog_snapshot);
 }
 
 void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
@@ -205,6 +208,10 @@ void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
        sr_session_destroy();
 
        set_capture_state(Stopped);
+
+       // Confirm that SR_DF_END was received
+       assert(!_cur_logic_snapshot);
+       assert(!_cur_analog_snapshot);
 }
 
 void SigSession::feed_in_header(const sr_dev_inst *sdi)