X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=9a3f197d4c2174edd3a9b814b9b340d1fc695fce;hb=ae1b6126c9a4e40ad2832e2b2e776f3a4a62e195;hp=9286a06cea256bae5d24d51d930658bd5fd99167;hpb=156f06e95f10587063b97b6b453a603751a0007c;p=pulseview.git diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 9286a06..9a3f197 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -303,8 +303,18 @@ shared_ptr MainWindow::add_session() void MainWindow::remove_session(shared_ptr session) { + // Determine the height of the button before it collapses int h = new_session_button_->height(); + // Stop capture while the session still exists so that the UI can be + // updated in case we're currently running. If so, this will schedule a + // call to our on_capture_state_changed() slot for the next run of the + // event loop. We need to have this executed immediately or else it will + // be dismissed since the session object will be deleted by the time we + // leave this method and the event loop gets a chance to run again. + session->stop_capture(); + QApplication::processEvents(); + for (shared_ptr view : session->views()) remove_view(view); @@ -316,6 +326,7 @@ void MainWindow::remove_session(shared_ptr session) if (last_focused_session_ == session) last_focused_session_.reset(); + // Remove the session from our list of sessions (which also destroys it) sessions_.remove_if([&](shared_ptr s) { return s == session; }); @@ -724,7 +735,8 @@ void MainWindow::on_tab_close_requested(int index) { shared_ptr session = get_tab_session(index); - assert(session); + if (!session) + return; if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"), tr("This session contains unsaved data. Close it anyway?"),