gstreamer: Use Value::from_type_unchecked() where applicable

Gets rid of some unnecessary assertions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1184>
This commit is contained in:
Sebastian Dröge 2023-01-05 18:55:38 +02:00
parent 89326c7e7c
commit 84720eee66
3 changed files with 5 additions and 4 deletions

View file

@ -64,7 +64,8 @@ where
{
unsafe {
let func_box: Box<dyn Fn(T) -> bool + Send + Sync + 'static> = Box::new(func);
let mut closure_value = glib::Value::from_type(from_glib(filter_boxed_get_type::<T>()));
let mut closure_value =
glib::Value::from_type_unchecked(from_glib(filter_boxed_get_type::<T>()));
glib::gobject_ffi::g_value_take_boxed(
closure_value.to_glib_none_mut().0,
Arc::into_raw(Arc::new(func_box)) as gpointer,
@ -137,7 +138,7 @@ where
let func_ptr = &mut func as *mut F as gpointer;
let mut accum = Some(init);
let mut ret = glib::Value::from_type(glib::Type::POINTER);
let mut ret = glib::Value::from_type_unchecked(glib::Type::POINTER);
glib::gobject_ffi::g_value_set_pointer(
ret.to_glib_none_mut().0,
&mut accum as *mut _ as gpointer,

View file

@ -112,7 +112,7 @@ macro_rules! bitflags_deserialize_impl {
return Ok(Self::Value::empty());
}
let mut gvalue = glib::Value::from_type(Self::Value::static_type());
let mut gvalue = unsafe { glib::Value::from_type_unchecked(Self::Value::static_type()) };
let tokens = value.split('+');
let class = FlagsClass::new(Self::Value::static_type()).unwrap();

View file

@ -1306,7 +1306,7 @@ impl GstValueExt for glib::Value {
assert_initialized_main_thread!();
unsafe {
let mut value = glib::Value::from_type(pspec.value_type());
let mut value = glib::Value::from_type_unchecked(pspec.value_type());
let ret: bool = from_glib(ffi::gst_value_deserialize_with_pspec(
value.to_glib_none_mut().0,
s.to_glib_none().0,