gstglwindow_x11.c: Fix colormap leak

This fixes an X server side memory leak, this is normally not severe
but in some circumstances where the glwindow is recreated frequently
it can result in a very bad memory leak.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4047>
This commit is contained in:
Tristan van Berkom 2023-02-22 15:05:56 +00:00
parent 81f121f244
commit 0472c306d0

View file

@ -62,6 +62,7 @@ struct _GstGLWindowX11Private
gboolean handle_events;
Colormap internal_colormap;
GstVideoRectangle render_rect;
};
@ -216,7 +217,7 @@ gst_gl_window_x11_create_window (GstGLWindowX11 * window_x11)
win_attr.background_pixel = 0;
win_attr.border_pixel = 0;
win_attr.colormap =
window_x11->priv->internal_colormap = win_attr.colormap =
XCreateColormap (window_x11->device, window_x11->root,
window_x11->visual_info->visual, AllocNone);
@ -272,6 +273,8 @@ gst_gl_window_x11_close (GstGLWindow * window)
XDestroyWindow (window_x11->device, window_x11->internal_win_id);
XFreeColormap (window_x11->device, window_x11->priv->internal_colormap);
/* Ensure everything is sent immediatly */
XSync (window_x11->device, FALSE);
}