From df4f222482a7c2a1116ef5c91ba6e4b55d94ad6c Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Fri, 23 Aug 2024 15:06:52 +0200 Subject: layersurface: remove layer on destroy from monitor (#7457) remove destroyed layer weakptrs on destroy, we can hit multiple null ptr derefs in renderering on mirroring and unmirroring displays otherwise. --- src/desktop/LayerSurface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index 8fd448ef..46aea86c 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -107,6 +107,12 @@ void CLayerSurface::onDestroy() { g_pHyprRenderer->damageBox(&geomFixed); } + for (auto& mon : g_pCompositor->m_vRealMonitors) { + for (auto& lsl : mon->m_aLayerSurfaceLayers) { + std::erase_if(lsl, [this](auto& ls) { return ls.expired() || ls.get() == this; }); + } + } + readyToDelete = true; layerSurface.reset(); if (surface) -- cgit v1.2.3