on xenial help sign in
Move the fix to the model level
commit4d6f8622b9fcd9128a4541a29c363a48663b4f6d authorJosh Arenson <joshua.arenson@canonical.com> dateWed 22 Mar 2017, 11:46 (10 years ago) parent32458de
3 files changed+11−7
plugins/LightDM/UsersModel.cpp+5 qml/Greeter/WideView.qml−6 tests/qmltests/Greeter/tst_WideView.qml+6−1
plugins/LightDM/UsersModel.cpp+5
@@ -109,6 +109,11 @@ QVariant MangleModel::data(const QModelIndex &index, int role) const
109109 variantData = stringData;
110110 }
111111
112+ // Workaround for liblightdm returning "" when a user has no default session
113+ if (Q_UNLIKELY(role == QLightDM::UsersModel::SessionRole && variantData.toString().length() == 0)) {
114+ variantData = Greeter::instance()->defaultSessionHint();
115+ }
116+
112117 return variantData;
113118}
114119
qml/Greeter/WideView.qml−6
@@ -142,12 +142,6 @@ FocusScope {
142142
143143 function setCurrentSession() {
144144 currentSession = LightDMService.users.data(currentIndex, LightDMService.userRoles.SessionRole);
145−
146− // If the user has never selected a session
147− // LightDM returns an empty string
148− if (!currentSession.length) {
149− currentSession = LightDMService.greeter.defaultSession
150− }
151145 }
152146 }
153147
tests/qmltests/Greeter/tst_WideView.qml+6−1
@@ -398,8 +398,13 @@ StyledItem {
398398 function test_sessionless_user_is_still_valid() {
399399 var loginList = findChild(view, "loginList")
400400
401+ /*
402+ * If a user has never logged in before, or, for some reason
403+ * has no sessionHint, ensure that the model returns the default
404+ * session and that the view respects this
405+ */
401406 selectUser("no-session");
402− compare(LightDM.Users.data(loginList.currentIndex, LightDM.UserRoles.SessionRole), "");
407+ compare(LightDM.Users.data(loginList.currentIndex, LightDM.UserRoles.SessionRole), LightDM.Greeter.defaultSession);
403408
404409 tryCompare(loginList, "currentSession", LightDM.Greeter.defaultSession);
405410 }