From 9a8a5738c6b883cd4dd77094cdc86919274c5c52 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 9 Apr 2023 18:52:43 +0100 Subject: [PATCH] internal: fix crash on scale change --- src/Hyprpaper.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Hyprpaper.cpp b/src/Hyprpaper.cpp index 840d307..6a76313 100644 --- a/src/Hyprpaper.cpp +++ b/src/Hyprpaper.cpp @@ -392,10 +392,14 @@ void CHyprpaper::destroyBuffer(SPoolBuffer* pBuffer) { } SPoolBuffer* CHyprpaper::getPoolBuffer(SMonitor* pMonitor, CWallpaperTarget* pWallpaperTarget) { - return std::find_if(m_vBuffers.begin(), m_vBuffers.end(), [&](const std::unique_ptr& el) { + const auto IT = std::find_if(m_vBuffers.begin(), m_vBuffers.end(), [&](const std::unique_ptr& el) { auto scale = std::round((pMonitor->pCurrentLayerSurface && pMonitor->pCurrentLayerSurface->pFractionalScaleInfo ? pMonitor->pCurrentLayerSurface->fScale : pMonitor->scale) * 120.0) / 120.0; return el->target == pWallpaperTarget->m_szPath && vectorDeltaLessThan(el->pixelSize, pMonitor->size * scale, 1); - })->get(); + }); + + if (IT == m_vBuffers.end()) + return nullptr; + return IT->get(); } void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {