Use downcast_unchecked() for sender in deep-notify signal handler

This is guaranteed to be of the correct type.
This commit is contained in:
Sebastian Dröge 2017-12-09 18:08:57 +02:00
parent d7792a4fca
commit 520a9bb879

View file

@ -7,10 +7,10 @@
// except according to those terms. // except according to those terms.
use glib; use glib;
use glib::{Cast, IsA}; use glib::IsA;
use glib::translate::ToGlibPtr; use glib::translate::ToGlibPtr;
use glib::signal::SignalHandlerId; use glib::signal::SignalHandlerId;
use glib::object::ObjectExt; use glib::object::{Downcast, ObjectExt};
use gobject_ffi; use gobject_ffi;
@ -29,7 +29,12 @@ impl<O: IsA<::Object> + IsA<glib::Object> + glib::value::SetValue> GstObjectExtM
f: F, f: F,
) -> SignalHandlerId { ) -> SignalHandlerId {
self.connect("deep-notify", false, move |values| { self.connect("deep-notify", false, move |values| {
let obj: O = values[0].get::<glib::Object>().unwrap().downcast().unwrap(); let obj: O = unsafe {
values[0]
.get::<glib::Object>()
.unwrap()
.downcast_unchecked()
};
let prop_obj: ::Object = values[1].get().unwrap(); let prop_obj: ::Object = values[1].get().unwrap();
let prop_name = unsafe { let prop_name = unsafe {