@@ -56,7 +56,8 @@ public:
56 this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)));
56 this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)));
57 // This next connect is how we pass ResponseFutures between threads
57 // This next connect is how we pass ResponseFutures between threads
58 connect(this, SIGNAL(showPrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)),
58 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);
62 ~GreeterImpl()
63 ~GreeterImpl()
@@ -79,7 +80,7 @@ public:
80 if (pam_start("lightdm", username.toUtf8(), &conversation, &pamHandle) == PAM_SUCCESS) {
81 if (pam_start("lightdm", username.toUtf8(), &conversation, &pamHandle) == PAM_SUCCESS) {
81 appData->handle = pamHandle;
82 appData->handle = pamHandle;
82− futureWatcher.setFuture(QtConcurrent::run(authenticateWithPam, pamHandle));
83+ futureWatcher.setFuture(QtConcurrent::mapped(QList<pam_handle*>() << pamHandle, authenticateWithPam));
84 delete appData;
85 delete appData;
85 greeterPrivate->authenticated = false;
86 greeterPrivate->authenticated = false;
@@ -88,7 +89,7 @@ public:
91− static int authenticateWithPam(pam_handle* pamHandle)
92+ static int authenticateWithPam(pam_handle* const& pamHandle)
93 int pamStatus = pam_authenticate(pamHandle, 0);
94 int pamStatus = pam_authenticate(pamHandle, 0);
94 if (pamStatus == PAM_SUCCESS) {
95 if (pamStatus == PAM_SUCCESS) {
@@ -242,11 +243,14 @@ private Q_SLOTS:
243 void cancelPam()
244 void cancelPam()
245− // Unfortunately we can't simply cancel our QFuture because QtConcurrent::run doesn't support cancel
246 if (pamHandle != nullptr) {
246 if (pamHandle != nullptr) {
247 pam_handle *handle = pamHandle;
247 pam_handle *handle = pamHandle;
248 pamHandle = nullptr; // to disable normal finishPam() handling
248 pamHandle = nullptr; // to disable normal finishPam() handling
249+ futureWatcher.future().cancel();
250+ while (!futureWatcher.future().isFinished()) {
251+ QCoreApplication::processEvents(); // let signal/slot handling happen
249− while (respond(QString())); // clear our local queue of QFutures
252+ respond(QString());
250 pam_end(handle, PAM_CONV_ERR);
254 pam_end(handle, PAM_CONV_ERR);
@@ -266,6 +270,11 @@ GreeterPrivate::GreeterPrivate(Greeter* parent)
273+GreeterPrivate::~GreeterPrivate()
269void GreeterPrivate::handleAuthenticate()
278void GreeterPrivate::handleAuthenticate()
271 m_impl->start(authenticationUser);
280 m_impl->start(authenticationUser);