]> sigrok.org Git - pulseview.git/commitdiff
Session: Improve session robustness
authorSoeren Apel <redacted>
Sun, 29 May 2016 15:21:13 +0000 (17:21 +0200)
committerUwe Hermann <redacted>
Fri, 24 Jun 2016 21:15:39 +0000 (23:15 +0200)
Don't try to start an acquisition if the device is undefined.

pv/session.cpp

index 6b7645bc7c7ef92e876e74076e062f7f532171c0..ba43ac21fb9c64d0d1b2711949fb417e4493c890 100644 (file)
@@ -195,10 +195,14 @@ Session::capture_state Session::get_capture_state() const
 
 void Session::start_capture(function<void (const QString)> error_handler)
 {
 
 void Session::start_capture(function<void (const QString)> error_handler)
 {
+       if (!device_) {
+               error_handler(tr("No active device set, can't start acquisition."));
+               return;
+       }
+
        stop_capture();
 
        // Check that at least one channel is enabled
        stop_capture();
 
        // Check that at least one channel is enabled
-       assert(device_);
        const shared_ptr<sigrok::Device> sr_dev = device_->device();
        if (sr_dev) {
                const auto channels = sr_dev->channels();
        const shared_ptr<sigrok::Device> sr_dev = device_->device();
        if (sr_dev) {
                const auto channels = sr_dev->channels();
@@ -460,7 +464,8 @@ void Session::sample_thread_proc(shared_ptr<devices::Device> device,
        assert(device);
        assert(error_handler);
 
        assert(device);
        assert(error_handler);
 
-       (void)device;
+       if (!device_)
+               return;
 
        cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);
 
 
        cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);