@@ -45,8 +45,9 @@ impl Drop for CallbackGuard {
45
45
}
46
46
}
47
47
48
- extern "C" fn trampoline ( func : & RefCell < Box < FnMut ( ) -> Continue + ' static > > ) -> gboolean {
48
+ unsafe extern "C" fn trampoline ( func : gpointer ) -> gboolean {
49
49
let _guard = CallbackGuard :: new ( ) ;
50
+ let func: & RefCell < Box < FnMut ( ) -> Continue + ' static > > = transmute ( func) ;
50
51
( & mut * func. borrow_mut ( ) ) ( ) . to_glib ( )
51
52
}
52
53
@@ -70,7 +71,7 @@ fn into_raw<F: FnMut() -> Continue + Send + 'static>(func: F) -> gpointer {
70
71
pub fn idle_add < F > ( func : F ) -> u32
71
72
where F : FnMut ( ) -> Continue + Send + ' static {
72
73
unsafe {
73
- glib_ffi:: g_idle_add_full ( glib_ffi:: G_PRIORITY_DEFAULT_IDLE , transmute ( trampoline) ,
74
+ glib_ffi:: g_idle_add_full ( glib_ffi:: G_PRIORITY_DEFAULT_IDLE , Some ( trampoline) ,
74
75
into_raw ( func) , Some ( destroy_closure) )
75
76
}
76
77
}
@@ -88,7 +89,7 @@ where F: FnMut() -> Continue + Send + 'static {
88
89
pub fn timeout_add < F > ( interval : u32 , func : F ) -> u32
89
90
where F : FnMut ( ) -> Continue + Send + ' static {
90
91
unsafe {
91
- glib_ffi:: g_timeout_add_full ( glib_ffi:: G_PRIORITY_DEFAULT , interval, transmute ( trampoline) ,
92
+ glib_ffi:: g_timeout_add_full ( glib_ffi:: G_PRIORITY_DEFAULT , interval, Some ( trampoline) ,
92
93
into_raw ( func) , Some ( destroy_closure) )
93
94
}
94
95
}
@@ -106,6 +107,6 @@ pub fn timeout_add_seconds<F>(interval: u32, func: F) -> u32
106
107
where F : FnMut ( ) -> Continue + Send + ' static {
107
108
unsafe {
108
109
glib_ffi:: g_timeout_add_seconds_full ( glib_ffi:: G_PRIORITY_DEFAULT , interval,
109
- transmute ( trampoline) , into_raw ( func) , Some ( destroy_closure) )
110
+ Some ( trampoline) , into_raw ( func) , Some ( destroy_closure) )
110
111
}
111
112
}
0 commit comments