forked from mirrors/gstreamer-rs
Ensure that miniobjects are writable before creating a mutable borrow
This commit is contained in:
parent
a3dffc2faa
commit
e88017f914
1 changed files with 4 additions and 3 deletions
|
@ -34,7 +34,7 @@ impl<T: MiniObject> GstRc<T> {
|
||||||
ffi::gst_mini_object_ref(ptr as *mut ffi::GstMiniObject);
|
ffi::gst_mini_object_ref(ptr as *mut ffi::GstMiniObject);
|
||||||
|
|
||||||
GstRc {
|
GstRc {
|
||||||
obj: ptr::NonNull::new_unchecked(T::from_mut_ptr(ptr as *mut T::GstType) as *mut T),
|
obj: ptr::NonNull::new_unchecked(ptr as *mut T::GstType as *mut T),
|
||||||
borrowed: false,
|
borrowed: false,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ impl<T: MiniObject> GstRc<T> {
|
||||||
assert!(!ptr.is_null());
|
assert!(!ptr.is_null());
|
||||||
|
|
||||||
GstRc {
|
GstRc {
|
||||||
obj: ptr::NonNull::new_unchecked(T::from_mut_ptr(ptr as *mut T::GstType) as *mut T),
|
obj: ptr::NonNull::new_unchecked(ptr as *mut T::GstType as *mut T),
|
||||||
borrowed: false,
|
borrowed: false,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl<T: MiniObject> GstRc<T> {
|
||||||
assert!(!ptr.is_null());
|
assert!(!ptr.is_null());
|
||||||
|
|
||||||
GstRc {
|
GstRc {
|
||||||
obj: ptr::NonNull::new_unchecked(T::from_mut_ptr(ptr as *mut T::GstType) as *mut T),
|
obj: ptr::NonNull::new_unchecked(ptr as *mut T::GstType as *mut T),
|
||||||
borrowed: true,
|
borrowed: true,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -187,6 +187,7 @@ where
|
||||||
|
|
||||||
unsafe fn from_mut_ptr<'a>(ptr: *mut Self::GstType) -> &'a mut Self {
|
unsafe fn from_mut_ptr<'a>(ptr: *mut Self::GstType) -> &'a mut Self {
|
||||||
assert!(!ptr.is_null());
|
assert!(!ptr.is_null());
|
||||||
|
assert_ne!(ffi::gst_mini_object_is_writable(ptr as *mut ffi::GstMiniObject), glib_ffi::GFALSE);
|
||||||
&mut *(ptr as *mut Self)
|
&mut *(ptr as *mut Self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue