X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=b8e98ece9a5dce42ce5e6e774e689bd34abed5a0;hp=ba43ac21fb9c64d0d1b2711949fb417e4493c890;hb=168bd8ac353d715257e7267dcf4eeb1aaef6365c;hpb=34c11fa778e0383d1f117a98be5e32479372022a diff --git a/pv/session.cpp b/pv/session.cpp index ba43ac21..b8e98ece 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -161,7 +161,15 @@ void Session::set_device(shared_ptr device) signals_changed(); device_ = std::move(device); - device_->open(); + + try { + device_->open(); + } catch (const QString &e) { + device_.reset(); + device_selected(); + throw; + } + device_->session()->add_datafeed_callback([=] (shared_ptr device, shared_ptr packet) { data_feed_in(device, packet); @@ -223,8 +231,7 @@ void Session::start_capture(function error_handler) // Begin the session sampling_thread_ = std::thread( - &Session::sample_thread_proc, this, device_, - error_handler); + &Session::sample_thread_proc, this, error_handler); } void Session::stop_capture() @@ -458,10 +465,8 @@ shared_ptr Session::signal_from_channel( return shared_ptr(); } -void Session::sample_thread_proc(shared_ptr device, - function error_handler) +void Session::sample_thread_proc(function error_handler) { - assert(device); assert(error_handler); if (!device_)