From 4631a806efc37662f8751dbd5d2848b7d8a2d8e4 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 7 Aug 2024 00:48:42 +0200 Subject: [PATCH] Provide a warning message when closing the window while an operation is ongoing. --- src/lay/lay/layMainWindow.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index dce7dd237..c60b09921 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -1331,6 +1331,18 @@ MainWindow::update_dock_widget_state () void MainWindow::exit () { + if (m_busy) { + if (QMessageBox::warning (this, + QObject::tr ("Application Busy - Close Anyway?"), + QObject::tr ("The application is busy.\nYou can close the application now, but this will terminate any running operations.\nDo you want to close anyway?\n\n" + "Press 'Yes' to end the application now."), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::Yes) != QMessageBox::Yes) + { + return; + } + } + m_exited = true; // If there is a operation ongoing, request a break and delay execution of the exit operation. @@ -1394,20 +1406,6 @@ MainWindow::dirty_files (std::string &dirty_files) bool MainWindow::can_close () { - if (m_busy) { - - bool can_close = false; - - can_close = (QMessageBox::warning (this, - QObject::tr ("Application Busy"), - QObject::tr ("The application is busy.\nYou can close the application now, but any unsaved data will be lost.\n\nPress 'Yes' to end the application now."), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::Yes) == QMessageBox::Yes); - - return can_close; - - } - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); if (! pd->can_exit (dispatcher ())) {