Do not leak the 1×1 buffer used for decorations

This commit is contained in:
Emmanuel Gil Peyrot 2017-12-26 20:06:33 +01:00 committed by linkmauve
parent 0c4ca85149
commit dfc7eacd50

View File

@ -247,18 +247,23 @@ static void createDecorations(_GLFWwindow* window)
if (!_glfw.wl.viewporter) if (!_glfw.wl.viewporter)
return; return;
struct wl_buffer* buffer = createShmBuffer(&image); if (!window->wl.decorations.buffer)
window->wl.decorations.buffer = createShmBuffer(&image);
createDecoration(&window->wl.decorations.top, window->wl.surface, buffer, createDecoration(&window->wl.decorations.top, window->wl.surface,
window->wl.decorations.buffer,
0, -_GLFW_DECORATION_TOP, 0, -_GLFW_DECORATION_TOP,
window->wl.width, _GLFW_DECORATION_TOP); window->wl.width, _GLFW_DECORATION_TOP);
createDecoration(&window->wl.decorations.left, window->wl.surface, buffer, createDecoration(&window->wl.decorations.left, window->wl.surface,
window->wl.decorations.buffer,
-_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP, -_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP,
_GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP); _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
createDecoration(&window->wl.decorations.right, window->wl.surface, buffer, createDecoration(&window->wl.decorations.right, window->wl.surface,
window->wl.decorations.buffer,
window->wl.width, -_GLFW_DECORATION_TOP, window->wl.width, -_GLFW_DECORATION_TOP,
_GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP); _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
createDecoration(&window->wl.decorations.bottom, window->wl.surface, buffer, createDecoration(&window->wl.decorations.bottom, window->wl.surface,
window->wl.decorations.buffer,
-_GLFW_DECORATION_WIDTH, window->wl.height, -_GLFW_DECORATION_WIDTH, window->wl.height,
window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH); window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
} }
@ -837,6 +842,8 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
window->context.destroy(window); window->context.destroy(window);
destroyDecorations(window); destroyDecorations(window);
if (window->wl.decorations.buffer)
wl_buffer_destroy(window->wl.decorations.buffer);
if (window->wl.native) if (window->wl.native)
wl_egl_window_destroy(window->wl.native); wl_egl_window_destroy(window->wl.native);