diff options
author | Vaxry <[email protected]> | 2023-12-06 14:46:18 +0000 |
---|---|---|
committer | Vaxry <[email protected]> | 2023-12-06 14:46:29 +0000 |
commit | 03c6f4506ab06d2920c59b3c64f45cb4eec8c97a (patch) | |
tree | 72aff88f74f89729f17e902e01eb488cb1eb1f0c | |
parent | 13b4c6de869b782ae18a0e8ac7c590e8000cc1c2 (diff) | |
download | Hyprland-03c6f4506ab06d2920c59b3c64f45cb4eec8c97a.tar.gz Hyprland-03c6f4506ab06d2920c59b3c64f45cb4eec8c97a.zip |
internal: various improvements to avoid crashes on exit
-rw-r--r-- | src/Compositor.cpp | 3 | ||||
-rw-r--r-- | src/Window.cpp | 3 | ||||
-rw-r--r-- | src/debug/Log.hpp | 4 | ||||
-rw-r--r-- | src/helpers/WLClasses.cpp | 3 | ||||
-rw-r--r-- | src/render/Renderbuffer.cpp | 3 | ||||
-rw-r--r-- | src/render/Renderer.cpp | 3 |
6 files changed, 18 insertions, 1 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 9419583e..98f51204 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -339,7 +339,8 @@ void CCompositor::cleanup() { removeLockFile(); - m_bIsShuttingDown = true; + m_bIsShuttingDown = true; + Debug::shuttingDown = true; #ifdef USES_SYSTEMD if (sd_booted() > 0) diff --git a/src/Window.cpp b/src/Window.cpp index bcb819a8..789882de 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -22,6 +22,9 @@ CWindow::~CWindow() { g_pCompositor->m_pLastWindow = nullptr; } + if (!g_pHyprOpenGL) + return; + g_pHyprRenderer->makeEGLCurrent(); std::erase_if(g_pHyprOpenGL->m_mWindowFramebuffers, [&](const auto& other) { return other.first == this; }); } diff --git a/src/debug/Log.hpp b/src/debug/Log.hpp index 659e2db4..d9a7f6aa 100644 --- a/src/debug/Log.hpp +++ b/src/debug/Log.hpp @@ -27,6 +27,7 @@ namespace Debug { inline int64_t* disableTime = nullptr; inline bool disableStdout = false; inline bool trace = false; + inline bool shuttingDown = false; inline std::string rollingLog = ""; // rolling log contains the ROLLING_LOG_SIZE tail of the log @@ -36,6 +37,9 @@ namespace Debug { if (level == TRACE && !trace) return; + if (shuttingDown) + return; + std::string logMsg = ""; switch (level) { diff --git a/src/helpers/WLClasses.cpp b/src/helpers/WLClasses.cpp index 9a326614..960145b9 100644 --- a/src/helpers/WLClasses.cpp +++ b/src/helpers/WLClasses.cpp @@ -9,6 +9,9 @@ SLayerSurface::SLayerSurface() { } SLayerSurface::~SLayerSurface() { + if (!g_pHyprOpenGL) + return; + g_pHyprRenderer->makeEGLCurrent(); std::erase_if(g_pHyprOpenGL->m_mLayerFramebuffers, [&](const auto& other) { return other.first == this; }); } diff --git a/src/render/Renderbuffer.cpp b/src/render/Renderbuffer.cpp index 0643904b..9434c3f0 100644 --- a/src/render/Renderbuffer.cpp +++ b/src/render/Renderbuffer.cpp @@ -5,6 +5,9 @@ #include <dlfcn.h> CRenderbuffer::~CRenderbuffer() { + if (!g_pCompositor) + return; + if (eglGetCurrentContext() != wlr_egl_get_context(g_pCompositor->m_sWLREGL)) eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL)); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index b7b6ae96..8206dc2b 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -2281,6 +2281,9 @@ CRenderbuffer* CHyprRenderer::getOrCreateRenderbuffer(wlr_buffer* buffer, uint32 } void CHyprRenderer::makeEGLCurrent() { + if (!g_pCompositor) + return; + if (eglGetCurrentContext() != wlr_egl_get_context(g_pCompositor->m_sWLREGL)) eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL)); } |