1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 05:42:03 +03:00

egl: add explicit drop impl for GlState

This tidies up the valgrind output some more, but seems to highlight
some leaks in the egl implementation around init/shutdown.

I still don't see a smoking gun for a memory leak that grows over time.

refs: https://github.com/wez/wezterm/issues/238
This commit is contained in:
Wez Furlong 2020-07-13 09:36:37 -07:00
parent 888cded0e3
commit dddf67e07a

View File

@ -50,6 +50,22 @@ pub struct GlState {
context: ffi::types::EGLContext,
}
impl Drop for GlState {
fn drop(&mut self) {
unsafe {
self.egl.egl.MakeCurrent(
self.display,
ffi::NO_SURFACE,
ffi::NO_SURFACE,
ffi::NO_CONTEXT,
);
self.egl.egl.DestroySurface(self.display, self.surface);
self.egl.egl.DestroyContext(self.display, self.context);
self.egl.egl.Terminate(self.display);
}
}
}
type GetProcAddressFunc =
unsafe extern "C" fn(*const std::os::raw::c_char) -> *const std::os::raw::c_void;
@ -67,7 +83,7 @@ impl EglWrapper {
Ok(Self { _lib: lib, egl })
}
pub fn get_display(
fn get_display(
&self,
display: Option<ffi::EGLNativeDisplayType>,
) -> anyhow::Result<ffi::types::EGLDisplay> {