mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-01 14:58:42 +00:00
Store GWeakRef in a Box
Its memory location is important, and having it stored directly inside the struct allows it to possible be moved to a different address.
This commit is contained in:
parent
24a10bb614
commit
50829bdec9
1 changed files with 5 additions and 5 deletions
|
@ -20,7 +20,7 @@ use gst;
|
||||||
|
|
||||||
pub struct GstDebugDrain {
|
pub struct GstDebugDrain {
|
||||||
category: *mut gst::GstDebugCategory,
|
category: *mut gst::GstDebugCategory,
|
||||||
element: gobject::GWeakRef,
|
element: Box<gobject::GWeakRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GstDebugDrain {
|
impl GstDebugDrain {
|
||||||
|
@ -51,12 +51,12 @@ impl GstDebugDrain {
|
||||||
|
|
||||||
let mut drain = GstDebugDrain {
|
let mut drain = GstDebugDrain {
|
||||||
category: category,
|
category: category,
|
||||||
element: unsafe { mem::zeroed() },
|
element: Box::new(unsafe { mem::zeroed() }),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !element.is_null() {
|
if !element.is_null() {
|
||||||
unsafe {
|
unsafe {
|
||||||
gobject::g_weak_ref_set(&mut drain.element, element as *mut gobject::GObject);
|
gobject::g_weak_ref_set(&mut *drain.element, element as *mut gobject::GObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ impl GstDebugDrain {
|
||||||
impl Drop for GstDebugDrain {
|
impl Drop for GstDebugDrain {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gobject::g_weak_ref_clear(&mut self.element);
|
gobject::g_weak_ref_clear(&mut *self.element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ impl Drain for GstDebugDrain {
|
||||||
let message_cstr = CString::new(fmt::format(record.msg()).as_bytes()).unwrap();
|
let message_cstr = CString::new(fmt::format(record.msg()).as_bytes()).unwrap();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let element = gobject::g_weak_ref_get(&self.element as *const gobject::GWeakRef as
|
let element = gobject::g_weak_ref_get(&*self.element as *const gobject::GWeakRef as
|
||||||
*mut gobject::GWeakRef);
|
*mut gobject::GWeakRef);
|
||||||
|
|
||||||
gst::gst_debug_log(self.category,
|
gst::gst_debug_log(self.category,
|
||||||
|
|
Loading…
Reference in a new issue