@@ -56,7 +56,8 @@ public:
5656 this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)));
5757 // This next connect is how we pass ResponseFutures between threads
5858 connect(this, SIGNAL(showPrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)),
59− this, SLOT(handlePrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)));
59+ this, SLOT(handlePrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)),
60+ Qt::BlockingQueuedConnection);
6061 }
6162
6263 ~GreeterImpl()
@@ -79,7 +80,7 @@ public:
7980
8081 if (pam_start("lightdm", username.toUtf8(), &conversation, &pamHandle) == PAM_SUCCESS) {
8182 appData->handle = pamHandle;
82− futureWatcher.setFuture(QtConcurrent::run(authenticateWithPam, pamHandle));
83+ futureWatcher.setFuture(QtConcurrent::mapped(QList<pam_handle*>() << pamHandle, authenticateWithPam));
8384 } else {
8485 delete appData;
8586 greeterPrivate->authenticated = false;
@@ -88,7 +89,7 @@ public:
8889 }
8990 }
9091
91− static int authenticateWithPam(pam_handle* pamHandle)
92+ static int authenticateWithPam(pam_handle* const& pamHandle)
9293 {
9394 int pamStatus = pam_authenticate(pamHandle, 0);
9495 if (pamStatus == PAM_SUCCESS) {
@@ -242,11 +243,14 @@ private Q_SLOTS:
242243private:
243244 void cancelPam()
244245 {
245− // Unfortunately we can't simply cancel our QFuture because QtConcurrent::run doesn't support cancel
246246 if (pamHandle != nullptr) {
247247 pam_handle *handle = pamHandle;
248248 pamHandle = nullptr; // to disable normal finishPam() handling
249− while (respond(QString())); // clear our local queue of QFutures
249+ futureWatcher.future().cancel();
250+ while (!futureWatcher.future().isFinished()) {
251+ QCoreApplication::processEvents(); // let signal/slot handling happen
252+ respond(QString());
253+ }
250254 pam_end(handle, PAM_CONV_ERR);
251255 }
252256 }
@@ -266,6 +270,11 @@ GreeterPrivate::GreeterPrivate(Greeter* parent)
266270{
267271}
268272
273+GreeterPrivate::~GreeterPrivate()
274+{
275+ delete m_impl;
276+}
277+
269278void GreeterPrivate::handleAuthenticate()
270279{
271280 m_impl->start(authenticationUser);