@@ -59,16 +59,15 @@ public:
5959 this, SLOT(handlePrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)));
6060 }
6161
62+ ~GreeterImpl()
63+ {
64+ cancelPam();
65+ }
66+
6267 void start(QString username)
6368 {
64− // Clear out any existing PAM interactions first (we can't simply
65− // cancel our QFuture because QtConcurrent::run doesn't support cancel)
66− if (pamHandle != NULL) {
67− pam_handle *handle = pamHandle;
68− pamHandle = NULL; // to disable normal finishPam() handling
69− while (respond(QString())); // clear our local queue of QFutures
70− pam_end(handle, PAM_CONV_ERR);
71− }
69+ // Clear out any existing PAM interactions first
70+ cancelPam();
7271
7372 AppData *appData = new AppData();
7473 appData->impl = this;
@@ -241,6 +240,17 @@ private Q_SLOTS:
241240 }
242241
243242private:
243+ void cancelPam()
244+ {
245+ // Unfortunately we can't simply cancel our QFuture because QtConcurrent::run doesn't support cancel
246+ if (pamHandle != NULL) {
247+ pam_handle *handle = pamHandle;
248+ pamHandle = NULL; // to disable normal finishPam() handling
249+ while (respond(QString())); // clear our local queue of QFutures
250+ pam_end(handle, PAM_CONV_ERR);
251+ }
252+ }
253+
244254 Greeter *greeter;
245255 GreeterPrivate *greeterPrivate;
246256 pam_handle* pamHandle;