]> sigrok.org Git - pulseview.git/blobdiff - pv/session.cpp
Introduce MainWindow::get_active_view()
[pulseview.git] / pv / session.cpp
index ba43ac21fb9c64d0d1b2711949fb417e4493c890..b8e98ece9a5dce42ce5e6e774e689bd34abed5a0 100644 (file)
@@ -161,7 +161,15 @@ void Session::set_device(shared_ptr<devices::Device> 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<sigrok::Device> device, shared_ptr<Packet> packet) {
                        data_feed_in(device, packet);
@@ -223,8 +231,7 @@ void Session::start_capture(function<void (const QString)> 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<view::Signal> Session::signal_from_channel(
        return shared_ptr<view::Signal>();
 }
 
-void Session::sample_thread_proc(shared_ptr<devices::Device> device,
-       function<void (const QString)> error_handler)
+void Session::sample_thread_proc(function<void (const QString)> error_handler)
 {
-       assert(device);
        assert(error_handler);
 
        if (!device_)