mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-06 07:01:57 -07:00
core: add a destructor to CHyprOpenglImpl and avoid wl_container_of undefined behaviour (#7101)
* protocols: avoid undefined behaviour in C macro to safely use wl_container_of with a class the class has to be no virtual functions, no inheritance, and uniform access control (e.g all public) work around this by putting this into a destroywrapper struct. * opengl: clean memory on destruction add a destructor and free the allocated memory and close the fd
This commit is contained in:
@@ -345,6 +345,22 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
|
||||
m_tGlobalTimer.reset();
|
||||
}
|
||||
|
||||
CHyprOpenGLImpl::~CHyprOpenGLImpl() {
|
||||
if (m_pEglDisplay && m_pEglContext != EGL_NO_CONTEXT)
|
||||
eglDestroyContext(m_pEglDisplay, m_pEglContext);
|
||||
|
||||
if (m_pEglDisplay)
|
||||
eglTerminate(m_pEglDisplay);
|
||||
|
||||
eglReleaseThread();
|
||||
|
||||
if (m_pGbmDevice)
|
||||
gbm_device_destroy(m_pGbmDevice);
|
||||
|
||||
if (m_iGBMFD >= 0)
|
||||
close(m_iGBMFD);
|
||||
}
|
||||
|
||||
std::optional<std::vector<uint64_t>> CHyprOpenGLImpl::getModsForFormat(EGLint format) {
|
||||
// TODO: return std::expected when clang supports it
|
||||
|
||||
|
Reference in New Issue
Block a user