@@ -32,7 +32,7 @@ pub fn pango_layout_get_clip_region(
32
32
}
33
33
34
34
#[ doc( alias = "gdk_content_deserialize_async" ) ]
35
- pub fn content_deserialize_async < R : FnOnce ( Result < glib:: Value , glib:: Error > ) + Send + ' static > (
35
+ pub fn content_deserialize_async < R : FnOnce ( Result < glib:: Value , glib:: Error > ) + ' static > (
36
36
stream : & impl IsA < gio:: InputStream > ,
37
37
mime_type : & str ,
38
38
type_ : glib:: types:: Type ,
@@ -51,9 +51,10 @@ pub fn content_deserialize_async<R: FnOnce(Result<glib::Value, glib::Error>) + S
51
51
"Async operations only allowed if the thread is owning the MainContext"
52
52
) ;
53
53
54
- let user_data: Box < R > = Box :: new ( callback) ;
54
+ let user_data: Box < glib:: thread_guard:: ThreadGuard < R > > =
55
+ Box :: new ( glib:: thread_guard:: ThreadGuard :: new ( callback) ) ;
55
56
unsafe extern "C" fn content_deserialize_async_trampoline <
56
- R : FnOnce ( Result < glib:: Value , glib:: Error > ) + Send + ' static ,
57
+ R : FnOnce ( Result < glib:: Value , glib:: Error > ) + ' static ,
57
58
> (
58
59
_source_object : * mut glib:: gobject_ffi:: GObject ,
59
60
res : * mut gio:: ffi:: GAsyncResult ,
@@ -67,7 +68,8 @@ pub fn content_deserialize_async<R: FnOnce(Result<glib::Value, glib::Error>) + S
67
68
} else {
68
69
Err ( from_glib_full ( error) )
69
70
} ;
70
- let callback: Box < R > = Box :: from_raw ( user_data as * mut _ ) ;
71
+ let callback: Box < glib:: thread_guard:: ThreadGuard < R > > = Box :: from_raw ( user_data as * mut _ ) ;
72
+ let callback = callback. into_inner ( ) ;
71
73
callback ( result) ;
72
74
}
73
75
let callback = content_deserialize_async_trampoline :: < R > ;
@@ -228,7 +230,7 @@ pub fn content_register_serializer<
228
230
}
229
231
230
232
#[ doc( alias = "gdk_content_serialize_async" ) ]
231
- pub fn content_serialize_async < R : FnOnce ( Result < ( ) , glib:: Error > ) + Send + ' static > (
233
+ pub fn content_serialize_async < R : FnOnce ( Result < ( ) , glib:: Error > ) + ' static > (
232
234
stream : & impl IsA < gio:: OutputStream > ,
233
235
mime_type : & str ,
234
236
value : & glib:: Value ,
@@ -246,9 +248,10 @@ pub fn content_serialize_async<R: FnOnce(Result<(), glib::Error>) + Send + 'stat
246
248
is_main_context_owner || has_acquired_main_context. is_some( ) ,
247
249
"Async operations only allowed if the thread is owning the MainContext"
248
250
) ;
249
- let user_data: Box < R > = Box :: new ( callback) ;
251
+ let user_data: Box < glib:: thread_guard:: ThreadGuard < R > > =
252
+ Box :: new ( glib:: thread_guard:: ThreadGuard :: new ( callback) ) ;
250
253
unsafe extern "C" fn content_serialize_async_trampoline <
251
- R : FnOnce ( Result < ( ) , glib:: Error > ) + Send + ' static ,
254
+ R : FnOnce ( Result < ( ) , glib:: Error > ) + ' static ,
252
255
> (
253
256
_source_object : * mut glib:: gobject_ffi:: GObject ,
254
257
res : * mut gio:: ffi:: GAsyncResult ,
@@ -261,7 +264,8 @@ pub fn content_serialize_async<R: FnOnce(Result<(), glib::Error>) + Send + 'stat
261
264
} else {
262
265
Err ( from_glib_full ( error) )
263
266
} ;
264
- let callback: Box < R > = Box :: from_raw ( user_data as * mut _ ) ;
267
+ let callback: Box < glib:: thread_guard:: ThreadGuard < R > > = Box :: from_raw ( user_data as * mut _ ) ;
268
+ let callback = callback. into_inner ( ) ;
265
269
callback ( result) ;
266
270
}
267
271
let callback = content_serialize_async_trampoline :: < R > ;
0 commit comments