03-offscreen-leak.patch revision 7204
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleyUpstream patch for gnome-shell memory leak recommended by gnome distros list
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elleyhttps://mail.gnome.org/archives/distributor-list/2016-March/msg00006.html
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleyFrom 4a8b9d62c98539972cf553fa8101567ce37d73c4 Mon Sep 17 00:00:00 2001
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleyFrom: Aaron Plattner <aplattner@nvidia.com>
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleyDate: Fri, 18 Mar 2016 16:00:05 -0700
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleySubject: [PATCH] st: Fix offscreen leak if cogl_framebuffer_allocate fails
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleyX-NVConfidentiality: public
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleyIf cogl_framebuffer_allocate fails in _st_create_shadow_pipeline_from_actor, the
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleyCoglOffscreen* that was allocated earlier in the function is leaked.
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elleyhttps://bugzilla.gnome.org/show_bug.cgi?id=735705
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir ElleySigned-off-by: Aaron Plattner <aplattner@nvidia.com>
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley 1 file changed, 1 insertion(+)
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elleydiff --git a/src/st/st-private.c b/src/st/st-private.c
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley@@ -425,40 +425,41 @@ _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley clutter_actor_get_allocation_box (actor, &box);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley clutter_actor_box_get_size (&box, &width, &height);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley if (width == 0 || height == 0)
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley return NULL;
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley buffer = cogl_texture_new_with_size (width,
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley COGL_TEXTURE_NO_SLICING,
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley COGL_PIXEL_FORMAT_ANY);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley if (buffer == NULL)
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley return NULL;
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley offscreen = cogl_offscreen_new_with_texture (buffer);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley fb = COGL_FRAMEBUFFER (offscreen);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley if (!cogl_framebuffer_allocate (fb, &catch_error))
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley cogl_error_free (catch_error);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley+ cogl_object_unref (offscreen);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley cogl_object_unref (buffer);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley return NULL;
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley /* XXX: There's no way to render a ClutterActor to an offscreen
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley * as it uses the implicit API. */
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley cogl_push_framebuffer (fb);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley G_GNUC_END_IGNORE_DEPRECATIONS;
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley cogl_framebuffer_translate (fb, -box.x1, -box.y1, 0);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley cogl_framebuffer_orthographic (fb, 0, 0, width, height, 0, 1.0);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley clutter_actor_set_opacity_override (actor, 255);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley clutter_actor_paint (actor);
28c155e20d3ebf53581821572c6c3fe1724582c9Yassir Elley clutter_actor_set_opacity_override (actor, -1);