Skip to content

Commit

Permalink
Change some code to use a wrapper struct
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
psychon committed Aug 17, 2024
1 parent bce8308 commit 431f6e0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions x11rb/src/cursor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ fn create_render_cursor<C: Connection>(
)
};

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
Expand Down Expand Up @@ -246,21 +245,20 @@ fn create_render_cursor<C: Connection>(
&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,
Expand Down

0 comments on commit 431f6e0

Please sign in to comment.