Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit bfa1c13

Browse files
committed
Don't box accumulator closure for signals twice
1 parent 051511a commit bfa1c13

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/subclass/types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,17 @@ pub(crate) unsafe fn add_signal_with_accumulator<F>(
527527
{
528528
let arg_types = arg_types.iter().map(|t| t.to_glib()).collect::<Vec<_>>();
529529

530-
let accumulator: Box<Box<Fn(&mut Value, &Value) -> bool + Send + Sync + 'static>> =
531-
Box::new(Box::new(accumulator));
530+
let accumulator: Box<F> = Box::new(accumulator);
532531

533-
unsafe extern "C" fn accumulator_trampoline(
532+
unsafe extern "C" fn accumulator_trampoline<
533+
F: Fn(&mut Value, &Value) -> bool + Send + Sync + 'static,
534+
>(
534535
_ihint: *mut gobject_ffi::GSignalInvocationHint,
535536
return_accu: *mut gobject_ffi::GValue,
536537
handler_return: *const gobject_ffi::GValue,
537538
data: ffi::gpointer,
538539
) -> ffi::gboolean {
539-
let accumulator: &&(Fn(&mut Value, &Value) -> bool + Send + Sync + 'static) =
540-
&*(data as *const &(Fn(&mut Value, &Value) -> bool + Send + Sync + 'static));
540+
let accumulator: &F = &*(data as *const &F);
541541
accumulator(
542542
&mut *(return_accu as *mut Value),
543543
&*(handler_return as *const Value),
@@ -550,7 +550,7 @@ pub(crate) unsafe fn add_signal_with_accumulator<F>(
550550
type_,
551551
gobject_ffi::G_SIGNAL_RUN_LAST,
552552
ptr::null_mut(),
553-
Some(accumulator_trampoline),
553+
Some(accumulator_trampoline::<F>),
554554
Box::into_raw(accumulator) as ffi::gpointer,
555555
None,
556556
ret_type.to_glib(),

0 commit comments

Comments
 (0)