Skip to content

Commit c13656f

Browse files
gdk: Mark Texture builders destroy callbacks as Send
As textures are thread-safe
1 parent ebfd15d commit c13656f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

gdk4/src/dmabuf_texture_builder.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ impl DmabufTextureBuilder {
3434
#[doc(alias = "gdk_dmabuf_texture_builder_build")]
3535
#[must_use = "The builder must be built to be used"]
3636
#[allow(clippy::missing_safety_doc)]
37-
pub unsafe fn build_with_release_func<F: FnOnce() + 'static>(
37+
pub unsafe fn build_with_release_func<F: FnOnce() + Send + 'static>(
3838
self,
3939
release_func: F,
4040
) -> Result<Texture, glib::Error> {
4141
let mut error = std::ptr::null_mut();
42-
unsafe extern "C" fn destroy_closure<F: FnOnce() + 'static>(func: glib::ffi::gpointer) {
42+
unsafe extern "C" fn destroy_closure<F: FnOnce() + Send + 'static>(
43+
func: glib::ffi::gpointer,
44+
) {
4345
let released_func = Box::<F>::from_raw(func as *mut _);
4446
released_func();
4547
}

gdk4/src/gl_texture_builder.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ impl GLTextureBuilder {
2525
#[doc(alias = "gdk_gl_texture_builder_build")]
2626
#[must_use = "The builder must be built to be used"]
2727
#[allow(clippy::missing_safety_doc)]
28-
pub unsafe fn build_with_release_func<F: FnOnce() + 'static>(self, release_func: F) -> Texture {
29-
unsafe extern "C" fn destroy_closure<F: FnOnce() + 'static>(func: glib::ffi::gpointer) {
28+
pub unsafe fn build_with_release_func<F: FnOnce() + Send + 'static>(
29+
self,
30+
release_func: F,
31+
) -> Texture {
32+
unsafe extern "C" fn destroy_closure<F: FnOnce() + Send + 'static>(
33+
func: glib::ffi::gpointer,
34+
) {
3035
let released_func = Box::<F>::from_raw(func as *mut _);
3136
released_func();
3237
}

0 commit comments

Comments
 (0)