Commit 63e92e6e authored by Jordan Petridis's avatar Jordan Petridis 🌱 Committed by Federico Mena Quintero

instance_ext.rs: Use ObjectExt::connect() instead of the unsafe bindings

Close #42
parent c98318d2
......@@ -88,7 +88,6 @@ pub fn slot_trait_impls<'ast>(names: &Names, slots: &[Slot<'ast>]) -> Vec<TokenS
Slot::Signal(ref signal) => {
let connect_signalname = signals::connect_signalname(signal);
let signalname_trampoline = signals::signal_trampoline_name(signal);
let sig = &signal.sig;
let signalname_str = signals::canonicalize_signal_name(&sig.name.to_string())
.expect("rust identifiers should always be canonicalizable");
......@@ -99,15 +98,10 @@ pub fn slot_trait_impls<'ast>(names: &Names, slots: &[Slot<'ast>]) -> Vec<TokenS
fn #connect_signalname<F: Fn(&Self, #input_types) #output + 'static>(&self, f: F) ->
glib::SignalHandlerId
{
unsafe {
let f: Box<Box<Fn(&Self, #input_types) #output + 'static>> =
Box::new(Box::new(f));
glib::signal::connect(self.to_glib_none().0,
#signalname_str,
mem::transmute(#signalname_trampoline::<Self> as usize),
Box::into_raw(f) as *mut _)
}
glib::ObjectExt::connect(self.to_glib_none().0,
#signalname_str,
false,
f).unwrap()
}
})
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment