gstreamer/miniobject: ToOwned::to_owned() on references has to create a copy

Otherwise it's possible to create a new owned reference from a mutable
reference, and then there is a mutable and immutable reference to the
same data at the same time, which is simply not allowed.

https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/204
This commit is contained in:
Sebastian Dröge 2019-05-17 16:14:23 +03:00 committed by Sebastian Dröge
parent c766f16403
commit e6f65a5032

View file

@ -855,10 +855,7 @@ macro_rules! gst_define_mini_object_wrapper(
type Owned = $name;
fn to_owned(&self) -> $name {
#[allow(clippy::cast_ptr_alignment)]
unsafe {
$name($crate::glib::translate::from_glib_none($crate::miniobject::MiniObject::as_ptr(self)))
}
self.copy()
}
}