From 2ed7ce2eeda62bfa4b08d9bb112b23c32135f3a5 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 11 Nov 2022 04:57:52 +0800 Subject: [PATCH] Cabana: confirm exit without saving (#26452) * confirm exit without saving * typo old-commit-hash: e08896c45d84f4005de156317ae902d601e9b895 --- tools/cabana/mainwin.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/cabana/mainwin.cc b/tools/cabana/mainwin.cc index 7ae97379f6..40a99a7a56 100644 --- a/tools/cabana/mainwin.cc +++ b/tools/cabana/mainwin.cc @@ -227,6 +227,16 @@ void MainWindow::dockCharts(bool dock) { } void MainWindow::closeEvent(QCloseEvent *event) { + if (detail_widget->undo_stack->index() > 0) { + auto ret = QMessageBox::question(this, tr("Unsaved Changes"), + tr("Are you sure you want to exit without saving?\nAny unsaved changes will be lost."), + QMessageBox::Yes | QMessageBox::No); + if (ret == QMessageBox::No) { + event->ignore(); + return; + } + } + main_win = nullptr; if (floating_window) floating_window->deleteLater();