From ea852965ffd4bf2bd2a74c0e821ba6190021eb31 Mon Sep 17 00:00:00 2001 From: nyx Date: Tue, 8 Apr 2025 13:43:15 -0400 Subject: [PATCH] xdg-shell: fix some null refs (#9992) --- src/desktop/Window.cpp | 4 ++-- src/managers/XWaylandManager.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 100300d4c..4b9a07fcb 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1237,7 +1237,7 @@ void CWindow::setSuspended(bool suspend) { if (suspend == m_bSuspended) return; - if (m_bIsX11 || !m_pXDGSurface->toplevel) + if (m_bIsX11 || !m_pXDGSurface || !m_pXDGSurface->toplevel) return; m_pXDGSurface->toplevel->setSuspeneded(suspend); @@ -1687,7 +1687,7 @@ Vector2D CWindow::requestedMinSize() { Vector2D CWindow::requestedMaxSize() { constexpr int NO_MAX_SIZE_LIMIT = 99999; - if (((m_bIsX11 && !m_pXWaylandSurface->sizeHints) || (!m_bIsX11 && !m_pXDGSurface->toplevel) || m_sWindowData.noMaxSize.valueOrDefault())) + if (((m_bIsX11 && !m_pXWaylandSurface->sizeHints) || (!m_bIsX11 && (!m_pXDGSurface || !m_pXDGSurface->toplevel)) || m_sWindowData.noMaxSize.valueOrDefault())) return Vector2D(NO_MAX_SIZE_LIMIT, NO_MAX_SIZE_LIMIT); Vector2D maxSize = m_bIsX11 ? Vector2D(m_pXWaylandSurface->sizeHints->max_width, m_pXWaylandSurface->sizeHints->max_height) : m_pXDGSurface->toplevel->layoutMaxSize(); diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 63b149629..9d2fda1d7 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -123,8 +123,10 @@ bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) { (SIZEHINTS && (SIZEHINTS->min_width == SIZEHINTS->max_width) && (SIZEHINTS->min_height == SIZEHINTS->max_height))) return true; } else { - const auto PSTATE = pending ? &pWindow->m_pXDGSurface->toplevel->pending : &pWindow->m_pXDGSurface->toplevel->current; + if (!pWindow->m_pXDGSurface || !pWindow->m_pXDGSurface->toplevel) + return false; + const auto PSTATE = pending ? &pWindow->m_pXDGSurface->toplevel->pending : &pWindow->m_pXDGSurface->toplevel->current; if (pWindow->m_pXDGSurface->toplevel->parent || (PSTATE->minSize.x != 0 && PSTATE->minSize.y != 0 && (PSTATE->minSize.x == PSTATE->maxSize.x || PSTATE->minSize.y == PSTATE->maxSize.y))) return true;