From 4d40d89f47ab84cfa000713d02e221a78b5677fb Mon Sep 17 00:00:00 2001 From: guolin Date: Thu, 20 Aug 2026 16:35:52 +0800 Subject: [PATCH] fix(session): guard null active session in xwayland primary output sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the weak_ptr lock result before dereferencing the active session. When an output is removed, primaryOutputChanged is delivered synchronously; if the active session was already reset (e.g. after a logind session was removed), calling ->xwayland() on the null session crashes the compositor. 输出移除时同步触发primaryOutputChanged,若活动会话已被重置, 对空指针调用->xwayland()会导致合成器崩溃,增加空指针守卫。 PMS: BUG-374551 Log: 修复输出移除(切 tty)时活动会话为空导致的崩溃 --- src/session/session.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/session/session.cpp b/src/session/session.cpp index d6d61c8e78..699f73a215 100644 --- a/src/session/session.cpp +++ b/src/session/session.cpp @@ -136,8 +136,12 @@ void SessionManager::syncActiveSessionXWaylandPrimaryOutput() if (!primaryOutput) return; + auto session = m_activeSession.lock(); + if (!session) + return; + const QString primaryOutputName = primaryOutput->output()->name(); - auto *xwayland = activeSession().lock()->xwayland(); + auto *xwayland = session->xwayland(); auto *connection = xwayland ? xwayland->xcbConnection() : nullptr; auto *screen = xwayland ? xwayland->xcbScreen() : nullptr; if (!connection || !screen)