From 1698d336f2511ee7c93d0a520c7ba3491c831e8d Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 29 Feb 2024 17:23:44 +0000 Subject: [PATCH] core: fix crashes on access of deleted wlr_ surface ref fixes #4893 --- src/events/Windows.cpp | 2 ++ src/managers/XWaylandManager.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 34a34cbd..1c1521c9 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -891,6 +891,8 @@ void Events::listener_destroyWindow(void* owner, void* data) { PWINDOW->m_bReadyToDelete = true; + PWINDOW->m_uSurface.xdg = nullptr; + if (!PWINDOW->m_bFadingOut) { Debug::log(LOG, "Unmapped {} removed instantly", PWINDOW); g_pCompositor->removeWindowFromVectorSafe(PWINDOW); // most likely X11 unmanaged or sumn diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 1704ee99..2dcb3bcc 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -107,6 +107,9 @@ std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) { return std::string(pWindow->m_uSurface.xwayland->title); } } else if (pWindow->m_uSurface.xdg) { + if (pWindow->m_bFadingOut || !pWindow->m_uSurface.xdg) + return ""; + if (pWindow->m_uSurface.xdg->toplevel && pWindow->m_uSurface.xdg->toplevel->title) { return std::string(pWindow->m_uSurface.xdg->toplevel->title); } @@ -128,6 +131,9 @@ std::string CHyprXWaylandManager::getAppIDClass(CWindow* pWindow) { return std::string(pWindow->m_uSurface.xwayland->_class); } } else if (pWindow->m_uSurface.xdg) { + if (pWindow->m_bFadingOut || !pWindow->m_uSurface.xdg) + return ""; + if (pWindow->m_uSurface.xdg->toplevel && pWindow->m_uSurface.xdg->toplevel->app_id) { return std::string(pWindow->m_uSurface.xdg->toplevel->app_id); }