From a0b8cfa7057fab7d354fa63f2c1d65580ddb4128 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 17 Aug 2024 15:54:00 +0200 Subject: [PATCH] Change some code to use a wrapper struct This should not have any externally visible effect, but I change some manual resource management for a picture to use a PictureWrapper instead, which frees things up in its Drop implementation. Signed-off-by: Uli Schlachter --- x11rb/src/cursor/mod.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/x11rb/src/cursor/mod.rs b/x11rb/src/cursor/mod.rs index e57b81a0..741c2b13 100644 --- a/x11rb/src/cursor/mod.rs +++ b/x11rb/src/cursor/mod.rs @@ -210,7 +210,6 @@ fn create_render_cursor( ) }; - let (cursor, picture) = (conn.generate_id()?, conn.generate_id()?); let (width, height) = (to_u16(image.width), to_u16(image.height)); // Get a pixmap of the right size and a gc for it @@ -246,21 +245,20 @@ fn create_render_cursor( &image.pixels_rgba, )?; - let _ = render::create_picture( + let picture = render::PictureWrapper::create_picture( conn, - picture, pixmap, handle.picture_format, &Default::default(), )?; + let cursor = conn.generate_id()?; let _ = render::create_cursor( conn, cursor, - picture, + picture.picture(), to_u16(image.xhot), to_u16(image.yhot), )?; - let _ = render::free_picture(conn, picture)?; Ok(render::Animcursorelt { cursor,