diff --git a/src/gl/x11.rs b/src/gl/x11.rs index b7aaca47..4a4de735 100644 --- a/src/gl/x11.rs +++ b/src/gl/x11.rs @@ -241,5 +241,9 @@ impl GlContext { } impl Drop for GlContext { - fn drop(&mut self) {} + fn drop(&mut self) { + unsafe { + glx::glXDestroyContext(self.display, self.context); + } + } } diff --git a/src/x11/window.rs b/src/x11/window.rs index 5b801eca..ca4db3cd 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -94,6 +94,10 @@ impl Drop for ParentHandle { } pub(crate) struct WindowInner { + // GlContext should be dropped **before** XcbConnection is dropped + #[cfg(feature = "opengl")] + gl_context: Option, + pub(crate) xcb_connection: XcbConnection, window_id: XWindow, pub(crate) window_info: WindowInfo, @@ -101,9 +105,6 @@ pub(crate) struct WindowInner { mouse_cursor: Cell, pub(crate) close_requested: Cell, - - #[cfg(feature = "opengl")] - gl_context: Option, } pub struct Window<'a> {