@@ -55,6 +55,8 @@ QVariantMap makeErrorObject(const QString& errorCode, const QString& errorMessag
5555
5656void interruptThread (QThread* thread)
5757{
58+ REQUIRE_NON_NULL (thread)
59+
5860 qDebug () << " Interrupting thread" << uintptr_t (thread);
5961 thread->disconnect ();
6062 thread->requestInterruption ();
@@ -274,9 +276,6 @@ void Controller::onCommandHandlerConfirmCompleted(const QVariantMap& res)
274276
275277 qDebug () << " Command completed" ;
276278
277- // Schedule application exit when the UI dialog is destroyed.
278- connect (window, &WebEidUI::destroyed, this , &Controller::exit);
279-
280279 try {
281280 _result = res;
282281 writeResponseToStdOut (isInStdinMode, res, commandHandler->commandType ());
@@ -286,6 +285,7 @@ void Controller::onCommandHandlerConfirmCompleted(const QVariantMap& res)
286285 }
287286
288287 window->quit ();
288+ exit ();
289289}
290290
291291void Controller::onRetry ()
@@ -331,29 +331,31 @@ void Controller::onDialogOK(const CardCertificateAndPinInfo& cardCertAndPinInfo)
331331
332332void Controller::onDialogCancel ()
333333{
334- REQUIRE_NON_NULL (window)
334+ stopCardEventMonitorThread ();
335335
336336 qDebug () << " User cancelled" ;
337337
338- // Schedule application exit when the UI dialog is destroyed.
339- connect (window, &WebEidUI::destroyed, this , &Controller::exit);
340-
341338 _result = makeErrorObject (RESP_USER_CANCEL, QStringLiteral (" User cancelled" ));
342339 writeResponseToStdOut (isInStdinMode, _result, commandType ());
340+
341+ exit ();
343342}
344343
345344void Controller::onPinPadCancel ()
346345{
347346 REQUIRE_NON_NULL (window)
348347
349- onDialogCancel ();
350348 window->quit ();
349+ onDialogCancel ();
351350}
352351
353352void Controller::onCriticalFailure (const QString& error)
354353{
354+ stopCardEventMonitorThread ();
355+
355356 qCritical () << " Exiting due to command" << std::string (commandType ())
356357 << " fatal error:" << error;
358+
357359 _result = makeErrorObject (RESP_TECH_ERROR, error);
358360 writeResponseToStdOut (isInStdinMode, _result, commandType ());
359361 disposeUI ();
0 commit comments