From: Emmanuele Bassi Date: Tue, 26 Sep 2023 11:57:52 +0000 (+0100) Subject: docs: Clarify the behaviour of gdk_texture_new_for_surface() X-Git-Tag: archive/raspbian/4.12.4+ds-3+rpi1^2~21^2~1^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6938d5aff2c17950337810732bd5079dc6c3c7ed;p=gtk4.git docs: Clarify the behaviour of gdk_texture_new_for_surface() Cairo surfaces are not GObject instances, so we should be more explicit in the behaviour of the memory management, to avoid leaks. --- diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c index ca53f036c2..01ed8dc43f 100644 --- a/gdk/gdktexture.c +++ b/gdk/gdktexture.c @@ -345,7 +345,9 @@ gdk_texture_init (GdkTexture *self) * * Creates a new texture object representing the surface. * - * @surface must be an image surface with format `CAIRO_FORMAT_ARGB32`. + * The @surface must be an image surface with format `CAIRO_FORMAT_ARGB32`. + * + * The newly created texture will acquire a reference on the @surface. * * Returns: a new `GdkTexture` */ @@ -364,7 +366,7 @@ gdk_texture_new_for_surface (cairo_surface_t *surface) * cairo_image_surface_get_stride (surface), (GDestroyNotify) cairo_surface_destroy, cairo_surface_reference (surface)); - + texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface), GDK_MEMORY_DEFAULT, @@ -819,7 +821,7 @@ gdk_texture_set_render_data (GdkTexture *self, GDestroyNotify notify) { g_return_val_if_fail (data != NULL, FALSE); - + if (self->render_key != NULL) return FALSE;