Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/session-widgets/sessionbasemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "sessionbasemodel.h"
#include "dconfig_helper.h"

Check warning on line 6 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dconfig_helper.h" not found.
#include "dbus/dbusdisplaymanager.h"

Check warning on line 7 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dbus/dbusdisplaymanager.h" not found.

#include <DSysInfo>

Check warning on line 9 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DSysInfo> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QDebug>

Check warning on line 10 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "dbusconstant.h"

Check warning on line 12 in src/session-widgets/sessionbasemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dbusconstant.h" not found.
#include "dconfig_helper.h"

DCORE_USE_NAMESPACE

Expand Down Expand Up @@ -462,6 +462,22 @@
void SessionBaseModel::updateLoginedUserList(const QString &list)
{
qCDebug(DDE_SHELL) << "Logined user list: " << list;
// kwin崩溃时systemd中的sessions不会被remove掉,这里通过DisplayManager的session信息过滤一遍(临时解决方案)
QStringList loggedUserNameList;
DBusDisplayManager displayManager("org.freedesktop.DisplayManager", "/org/freedesktop/DisplayManager", QDBusConnection::systemBus());
const auto &sessions = displayManager.sessions();
for (const auto &session : sessions) {
const QString &sessionPath = session.path();
if (sessionPath.isEmpty())
continue;
QDBusInterface interface("org.freedesktop.DisplayManager", sessionPath, "org.freedesktop.DisplayManager.Session", QDBusConnection::systemBus());
if (interface.isValid()) {
const QString &userName = interface.property("UserName").toString();
if (!userName.isEmpty())
loggedUserNameList.append(userName);
}
}
qInfo(DDE_SHELL) << "Logined users from display manager: " << loggedUserNameList;

QList<QString> loginedUsersTmp = m_loginedUsers->keys();
QJsonParseError jsonParseError;
Expand All @@ -486,8 +502,11 @@
// 对于通过自定义窗口输入的账户(域账户), 此时账户还没添加进来,导致下面m_users->value(path)为空指针,调用会导致程序奔溃
// 因此在登录时,对于新增的账户,调用addUser先将账户添加进来,然后再去更新对应账户的登录状态
addUser(path);
m_loginedUsers->insert(path, m_users->value(path));
m_users->value(path)->updateLoginState(true);
auto user = m_users->value(path);
if (user->name().isEmpty() || loggedUserNameList.contains(user->name())) {
m_loginedUsers->insert(path, user);
user->updateLoginState(true);
}
} else {
loginedUsersTmp.removeAll(path);
}
Expand Down