X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;fp=pv%2Fmainwindow.cpp;h=8e3cb9d1085f9c72588c519dc74e9e5bbb8b8179;hp=6749b5f0343517a6c0afb467f8907f7878dcd38f;hb=5d58e6ce2b4b0e786edb3945953e59a664685c1a;hpb=e505bec82f581f838bdcaae3c75bce96676cc9fd;ds=sidebyside diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 6749b5f0..8e3cb9d1 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -661,20 +661,51 @@ bool MainWindow::restoreState(const QByteArray &state, int version) void MainWindow::on_run_stop_clicked() { - shared_ptr session = last_focused_session_; + GlobalSettings settings; + bool all_sessions = settings.value(GlobalSettings::Key_General_StartAllSessions).toBool(); - if (!session) - return; + if (all_sessions) + { + vector< shared_ptr > hw_sessions; + + // Make a list of all sessions where a hardware device is used + for (shared_ptr s : sessions_) { + shared_ptr hw_device = + dynamic_pointer_cast< devices::HardwareDevice >(s->device()); + if (!hw_device) + continue; + hw_sessions.push_back(s); + } + + // Stop all acquisitions if there are any running ones, start all otherwise + bool any_running = any_of(hw_sessions.begin(), hw_sessions.end(), + [](const shared_ptr &s) + { return (s->get_capture_state() == Session::AwaitingTrigger) || + (s->get_capture_state() == Session::Running); }); + + for (shared_ptr s : hw_sessions) + if (any_running) + s->stop_capture(); + else + s->start_capture([&](QString message) { + show_session_error("Capture failed", message); }); + } else { + + shared_ptr session = last_focused_session_; + + if (!session) + return; - switch (session->get_capture_state()) { - case Session::Stopped: - session->start_capture([&](QString message) { - show_session_error("Capture failed", message); }); - break; - case Session::AwaitingTrigger: - case Session::Running: - session->stop_capture(); - break; + switch (session->get_capture_state()) { + case Session::Stopped: + session->start_capture([&](QString message) { + show_session_error("Capture failed", message); }); + break; + case Session::AwaitingTrigger: + case Session::Running: + session->stop_capture(); + break; + } } }