From: Soeren Apel Date: Sun, 29 May 2016 15:21:13 +0000 (+0200) Subject: Session: Improve session robustness X-Git-Tag: pulseview-0.4.0~291 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=34c11fa778e0383d1f117a98be5e32479372022a;p=pulseview.git Session: Improve session robustness Don't try to start an acquisition if the device is undefined. --- diff --git a/pv/session.cpp b/pv/session.cpp index 6b7645bc..ba43ac21 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -195,10 +195,14 @@ Session::capture_state Session::get_capture_state() const void Session::start_capture(function 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 - assert(device_); const shared_ptr sr_dev = device_->device(); if (sr_dev) { const auto channels = sr_dev->channels(); @@ -460,7 +464,8 @@ void Session::sample_thread_proc(shared_ptr device, assert(device); assert(error_handler); - (void)device; + if (!device_) + return; cur_samplerate_ = device_->read_config(ConfigKey::SAMPLERATE);