]> sigrok.org Git - pulseview.git/blobdiff - pv/sigsession.cpp
Keep Run/Stop button state updated
[pulseview.git] / pv / sigsession.cpp
index 580b6796c680f8a76c679dfad20d7ea11640aaa4..e4a58a6190af8bc023c31297751cfd7ccf430596 100644 (file)
@@ -94,8 +94,6 @@ void SigSession::stop_capture()
        if(_sampling_thread.get())
                _sampling_thread->join();
        _sampling_thread.reset();
-
-       _capture_state = Stopped;
 }
 
 vector< shared_ptr<view::Signal> > SigSession::get_signals()
@@ -109,6 +107,13 @@ boost::shared_ptr<LogicData> SigSession::get_data()
        return _logic_data;
 }
 
+void SigSession::set_capture_state(capture_state state)
+{
+       lock_guard<mutex> lock(_state_mutex);
+       _capture_state = state;
+       capture_state_changed(state);
+}
+
 void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
        uint64_t record_length, uint64_t sample_rate)
 {
@@ -140,13 +145,12 @@ void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
                return;
        }
 
-       {
-               lock_guard<mutex> lock(_state_mutex);
-               _capture_state = Running;
-       }
+       set_capture_state(Running);
 
        sr_session_run();
        sr_session_destroy();
+
+       set_capture_state(Stopped);
 }
 
 void SigSession::data_feed_in(const struct sr_dev_inst *sdi,