diff --git a/src/core/treeland.cpp b/src/core/treeland.cpp index f642fd3e74..bd2b79a4cf 100644 --- a/src/core/treeland.cpp +++ b/src/core/treeland.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Dingyuan Zhang . +// Copyright (C) 2023-2026 Dingyuan Zhang . // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "treeland.h" @@ -314,7 +314,10 @@ Treeland::Treeland() d->init(); auto globalSession = d->helper->sessionManager()->globalSession(); - Q_ASSERT(globalSession); + if (!globalSession) { + qCCritical(lcTlCore) << "Global session is null, skipping initialization"; + return; + } if (CmdLine::ref().run().has_value()) { auto exec = [runCmd = CmdLine::ref().run().value(), d, globalSession] { diff --git a/src/greeter/usermodel.cpp b/src/greeter/usermodel.cpp index 97b65b767f..978fe12417 100644 --- a/src/greeter/usermodel.cpp +++ b/src/greeter/usermodel.cpp @@ -63,7 +63,8 @@ UserModel::UserModel(QObject *parent) auto userList = d->manager.userList(); if (!userList) { - qFatal() << userList.error(); + qCWarning(lcTlGreeter) << "Failed to get user list:" << userList.error(); + return; } const auto uids = userList.value(); @@ -95,8 +96,12 @@ UserModel::UserModel(QObject *parent) } if (d->currentUserName.isEmpty()) { - qCWarning(lcTlGreeter) << "Couldn't find last user, using current running user as current user"; - d->currentUserName = d->users.first()->userName(); + if (d->users.isEmpty()) { + qCWarning(lcTlGreeter) << "No users found, currentUserName remains empty"; + } else { + qCWarning(lcTlGreeter) << "Couldn't find last user, using current running user as current user"; + d->currentUserName = d->users.first()->userName(); + } } } diff --git a/src/session/session.cpp b/src/session/session.cpp index d6d61c8e78..00dfaed051 100644 --- a/src/session/session.cpp +++ b/src/session/session.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #define _DEEPIN_NO_TITLEBAR "_DEEPIN_NO_TITLEBAR" @@ -381,8 +382,13 @@ std::shared_ptr SessionManager::ensureSession(int id, QString username) // Session does not exist, create new session with deleter auto passwd = getpwnam(username.toLocal8Bit().data()); if (!passwd) { - qCWarning(lcTlCore) << "Failed to get passwd entry for user:" << username; - return nullptr; + qCWarning(lcTlCore) << "Failed to get passwd entry for user:" << username + << ", falling back to current user uid"; + passwd = getpwuid(getuid()); + if (!passwd) { + qCCritical(lcTlCore) << "Failed to get passwd entry for current user"; + return nullptr; + } } auto session = std::make_shared(); session->m_id = id;