From 2ae79757d5e5c48de2f4284992a6bfa265853a2d Mon Sep 17 00:00:00 2001 From: Staz Modrzynski <9014588+stazio@users.noreply.github.com> Date: Sun, 17 Mar 2024 11:44:37 -0400 Subject: [PATCH] core: Add missing destructors causing segfaults (#199) Co-authored-by: Staz M --- src/core/Egl.cpp | 6 ++++++ src/core/Egl.hpp | 1 + src/core/hyprlock.cpp | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/core/Egl.cpp b/src/core/Egl.cpp index 71956a6..4a0d0b3 100644 --- a/src/core/Egl.cpp +++ b/src/core/Egl.cpp @@ -69,6 +69,12 @@ CEGL::CEGL(wl_display* display) { error: eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); +} + +CEGL::~CEGL() { + if (eglContext != EGL_NO_CONTEXT) + eglDestroyContext(eglDisplay, eglContext); + if (eglDisplay) eglTerminate(eglDisplay); diff --git a/src/core/Egl.hpp b/src/core/Egl.hpp index 55f1db0..52cbb59 100644 --- a/src/core/Egl.hpp +++ b/src/core/Egl.hpp @@ -9,6 +9,7 @@ class CEGL { public: CEGL(wl_display*); + ~CEGL(); EGLDisplay eglDisplay; EGLConfig eglConfig; diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index 98f5f4b..62ee383 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -519,6 +519,9 @@ void CHyprlock::run() { m_vOutputs.clear(); g_pEGL.reset(); + g_pRenderer = nullptr; + + xkb_context_unref(m_pXKBContext); wl_display_disconnect(m_sWaylandState.display);