From 8217dabc80814b6d2741dc0a75c8398fc770b26c Mon Sep 17 00:00:00 2001 From: James Bingen <47846774+CptHuba@users.noreply.github.com> Date: Tue, 10 Mar 2026 11:04:50 +0100 Subject: layout: fix null deref in focalPointForDir and moveInDirection (#13652) Added a guard against expired m_parent weak pointer in IModeAlgorithm::focalPointForDir when the fullscreen monitor path is taken, and also added a null check in CLayoutManager::moveInDirection. This seemed to have fixed a segfault triggered by a 3-finger swipe gesture end on a fullscreen tiled window. --- src/layout/algorithm/ModeAlgorithm.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/layout/algorithm') diff --git a/src/layout/algorithm/ModeAlgorithm.cpp b/src/layout/algorithm/ModeAlgorithm.cpp index dea5bb17..2fea2b68 100644 --- a/src/layout/algorithm/ModeAlgorithm.cpp +++ b/src/layout/algorithm/ModeAlgorithm.cpp @@ -18,8 +18,21 @@ std::optional IModeAlgorithm::predictSizeForNewTarget() { std::optional IModeAlgorithm::focalPointForDir(SP t, Math::eDirection dir) { Vector2D focalPoint; - const auto WINDOWIDEALBB = - t->fullscreenMode() != FSMODE_NONE ? m_parent->space()->workspace()->m_monitor->logicalBox() : t->window()->getWindowIdealBoundingBoxIgnoreReserved(); + const auto getFullscreenBB = [&]() -> std::optional { + const auto PARENT = m_parent.lock(); + if (!PARENT) + return std::nullopt; + const auto SPACE = PARENT->space(); + if (!SPACE) + return std::nullopt; + const auto WS = SPACE->workspace(); + if (!WS || !WS->m_monitor) + return std::nullopt; + return WS->m_monitor->logicalBox(); + }; + + const auto WINDOWIDEALBB = t->fullscreenMode() != FSMODE_NONE ? getFullscreenBB().value_or(t->window()->getWindowIdealBoundingBoxIgnoreReserved()) : + t->window()->getWindowIdealBoundingBoxIgnoreReserved(); switch (dir) { case Math::DIRECTION_UP: focalPoint = WINDOWIDEALBB.pos() + Vector2D{WINDOWIDEALBB.size().x / 2.0, -1.0}; break; -- cgit v1.2.3