on xenial help sign in
Cache auth user so we don't send change emission more than once; fixes CI test
commitebd7b5bba6d03f4951aaa4ea071c75bce9df8f45 authorMichael Terry <mike@mterry.name> dateThu 12 Jan 2017, 14:59 (10 years ago) parente5a2091
3 files changed+22−10
plugins/LightDM/Greeter.cpp+13−4 plugins/LightDM/Greeter.h+1 plugins/LightDM/GreeterPrivate.h+8−6
plugins/LightDM/Greeter.cpp+13−4
@@ -83,7 +83,16 @@ bool Greeter::isAuthenticated() const
8383QString Greeter::authenticationUser() const
8484{
8585 Q_D(const Greeter);
86− return d->m_greeter->authenticationUser();
86+ return d->cachedAuthUser;
87+}
88+
89+void Greeter::checkAuthenticationUser()
90+{
91+ Q_D(Greeter);
92+ if (d->cachedAuthUser != d->m_greeter->authenticationUser()) {
93+ d->cachedAuthUser = d->m_greeter->authenticationUser();
94+ Q_EMIT authenticationUserChanged();
95+ }
8796}
8897
8998QString Greeter::defaultSessionHint() const
@@ -144,7 +153,7 @@ void Greeter::authenticate(const QString &username)
144153 }
145154
146155 Q_EMIT isAuthenticatedChanged();
147− Q_EMIT authenticationUserChanged();
156+ checkAuthenticationUser();
148157}
149158
150159void Greeter::respond(const QString &response)
@@ -164,7 +173,7 @@ void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptTyp
164173 Q_D(Greeter);
165174 d->wasPrompted = true;
166175
167− Q_EMIT authenticationUserChanged(); // may have changed in liblightdm
176+ checkAuthenticationUser(); // may have changed in liblightdm
168177
169178 bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "));
170179
@@ -185,7 +194,7 @@ void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptTyp
185194
186195void Greeter::showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type)
187196{
188− Q_EMIT authenticationUserChanged(); // may have changed in liblightdm
197+ checkAuthenticationUser(); // may have changed in liblightdm
189198 Q_EMIT showMessage(text, type == QLightDM::Greeter::MessageTypeError);
190199}
191200
plugins/LightDM/Greeter.h+1
@@ -85,4 +85,5 @@ private Q_SLOTS:
8585 void showMessageFilter(const QString &text, QLightDM::Greeter::MessageType type);
8686 void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
8787 void authenticationCompleteFilter();
88+ void checkAuthenticationUser();
8889};
plugins/LightDM/GreeterPrivate.h+8−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2015-2017 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -14,10 +14,13 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−#ifndef UNITY_GREETER_PRIVATE_H
18−#define UNITY_GREETER_PRIVATE_H
17+#pragma once
1918
20−#include <QLightDM/Greeter>
19+#include <QObject>
20+
21+namespace QLightDM {
22+ class Greeter;
23+}
2124
2225class GreeterPrivate
2326{
@@ -28,6 +31,7 @@ public:
2831 bool m_active;
2932 bool wasPrompted;
3033 bool promptless;
34+ QString cachedAuthUser;
3135
3236protected:
3337 Greeter * const q_ptr;
@@ -35,5 +39,3 @@ protected:
3539private:
3640 Q_DECLARE_PUBLIC(Greeter)
3741};
38−
39−#endif // UNITY_GREETER_PRIVATE_H