From dfc7eacd508709f25f4cbbfa16d3f6e50a1112cf Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 26 Dec 2017 20:06:33 +0100 Subject: [PATCH] =?UTF-8?q?Do=20not=20leak=20the=201=C3=971=20buffer=20use?= =?UTF-8?q?d=20for=20decorations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wl_window.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index dcd5e4e0..90db32fa 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -247,18 +247,23 @@ static void createDecorations(_GLFWwindow* window) if (!_glfw.wl.viewporter) 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, 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, 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, _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, window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH); } @@ -837,6 +842,8 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) window->context.destroy(window); destroyDecorations(window); + if (window->wl.decorations.buffer) + wl_buffer_destroy(window->wl.decorations.buffer); if (window->wl.native) wl_egl_window_destroy(window->wl.native);