Skip to content

Commit 9b59ec1

Browse files
committed
Fix confirming exit when commands are running
1 parent c9129a1 commit 9b59ec1

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/app/clipboardserver.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <QMenu>
3636
#include <QMessageBox>
3737
#include <QMimeData>
38+
#include <QPushButton>
3839
#include <QSessionManager>
3940
#include <QStyleFactory>
4041
#include <QTextEdit>
@@ -370,19 +371,20 @@ bool ClipboardServer::askToQuit()
370371
m_wnd );
371372

372373
messageBox.addButton(tr("Cancel Exiting"), QMessageBox::RejectRole);
373-
messageBox.addButton(tr("Exit Anyway"), QMessageBox::AcceptRole);
374+
QAbstractButton *exitButton = messageBox.addButton(tr("Exit Anyway"), QMessageBox::AcceptRole);
374375

375376
// Close the message box automatically after all running commands finish.
376377
QTimer timerCheckRunningCommands;
377378
timerCheckRunningCommands.setInterval(1000);
378379
connect( &timerCheckRunningCommands, &QTimer::timeout,
379-
this, [&]() {
380+
exitButton, [&]() {
380381
if ( !hasRunningCommands() )
381-
messageBox.accept();
382+
exitButton->click();
382383
});
383384
timerCheckRunningCommands.start();
384385

385-
return messageBox.exec() == QMessageBox::Accepted;
386+
messageBox.exec();
387+
return exitButton == messageBox.clickedButton();
386388
}
387389

388390
return true;

src/tests/tests.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4775,6 +4775,15 @@ void Tests::exitNoConfirm()
47754775
TEST( m_test->waitForServerToStop() );
47764776
}
47774777

4778+
void Tests::exitStopCommands()
4779+
{
4780+
RUN("config" << "confirm_exit" << "false", "false\n");
4781+
RUN("action" << "copyq sleep 999999", "");
4782+
RUN("keys" << clipboardBrowserId << "CTRL+Q", "");
4783+
RUN("keys" << confirmExitDialogId << "ENTER", "");
4784+
TEST( m_test->waitForServerToStop() );
4785+
}
4786+
47784787
void Tests::abortInputReader()
47794788
{
47804789
RUN_WITH_INPUT("afterMilliseconds(0, abort); input(); 'DONE'", KEEP_STDIN_OPEN, "");

src/tests/tests.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ private slots:
295295

296296
void exitConfirm();
297297
void exitNoConfirm();
298+
void exitStopCommands();
298299

299300
void abortInputReader();
300301

0 commit comments

Comments
 (0)