forked from mirrors/gstreamer-rs
gstreamer/bin: Take a strong reference of the element passed into remove_element()
It might be gone once we called into the parent class' implementation so we need to keep a strong reference around here. Also we need to ensure that we don't accidentally steal a floating reference from the caller here: if the element is still floating it is apparently not part of this bin and we can directly return FALSE.
This commit is contained in:
parent
bef1143df3
commit
802fa4fcb4
1 changed files with 8 additions and 1 deletions
|
@ -140,8 +140,15 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: Bin = from_glib_borrow(ptr);
|
let wrap: Bin = from_glib_borrow(ptr);
|
||||||
|
|
||||||
|
// If we get a floating reference passed simply return FALSE here. It can't be
|
||||||
|
// stored inside this bin, and if we continued to use it we would take ownership
|
||||||
|
// of this floating reference.
|
||||||
|
if gobject_sys::g_object_is_floating(element as *mut gobject_sys::GObject) != glib_sys::GFALSE {
|
||||||
|
return glib_sys::GFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.remove_element(&wrap, &from_glib_borrow(element)) {
|
match imp.remove_element(&wrap, &from_glib_none(element)) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&wrap);
|
err.log_with_object(&wrap);
|
||||||
|
|
Loading…
Reference in a new issue