diff --git a/src/app/clipboardserver.cpp b/src/app/clipboardserver.cpp index 295b9bc88..aa000a92e 100644 --- a/src/app/clipboardserver.cpp +++ b/src/app/clipboardserver.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -370,19 +371,20 @@ bool ClipboardServer::askToQuit() m_wnd ); messageBox.addButton(tr("Cancel Exiting"), QMessageBox::RejectRole); - messageBox.addButton(tr("Exit Anyway"), QMessageBox::AcceptRole); + QAbstractButton *exitButton = messageBox.addButton(tr("Exit Anyway"), QMessageBox::AcceptRole); // Close the message box automatically after all running commands finish. QTimer timerCheckRunningCommands; timerCheckRunningCommands.setInterval(1000); connect( &timerCheckRunningCommands, &QTimer::timeout, - this, [&]() { + exitButton, [&]() { if ( !hasRunningCommands() ) - messageBox.accept(); + exitButton->click(); }); timerCheckRunningCommands.start(); - return messageBox.exec() == QMessageBox::Accepted; + messageBox.exec(); + return exitButton == messageBox.clickedButton(); } return true; diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 23c8643d3..abe6f69d7 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -4775,6 +4775,15 @@ void Tests::exitNoConfirm() TEST( m_test->waitForServerToStop() ); } +void Tests::exitStopCommands() +{ + RUN("config" << "confirm_exit" << "false", "false\n"); + RUN("action" << "copyq sleep 999999", ""); + RUN("keys" << clipboardBrowserId << "CTRL+Q", ""); + RUN("keys" << confirmExitDialogId << "ENTER", ""); + TEST( m_test->waitForServerToStop() ); +} + void Tests::abortInputReader() { RUN_WITH_INPUT("afterMilliseconds(0, abort); input(); 'DONE'", KEEP_STDIN_OPEN, ""); diff --git a/src/tests/tests.h b/src/tests/tests.h index 040aaf87a..096fbd96c 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -295,6 +295,7 @@ private slots: void exitConfirm(); void exitNoConfirm(); + void exitStopCommands(); void abortInputReader();