docs: Clarify the behaviour of gdk_texture_new_for_surface()
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 26 Sep 2023 11:57:52 +0000 (12:57 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 28 Sep 2023 00:42:45 +0000 (20:42 -0400)
Cairo surfaces are not GObject instances, so we should be more explicit
in the behaviour of the memory management, to avoid leaks.

gdk/gdktexture.c

index ca53f036c2c88bb3f4f625268b2406820147ce86..01ed8dc43f8044c5af29ce0e7128a04d354016c0 100644 (file)
@@ -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;