gstreamer/pad: Use the correct type for destroying the pad task closure data

It's a Box<RefCell<_>> and not a plain Box<_> like for the other pad
functions, and doing this wrong causes crashes at runtime.
This commit is contained in:
Sebastian Dröge 2019-03-01 19:49:27 +02:00
parent 23a776ea63
commit 631eee13da

View file

@ -704,7 +704,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
self.as_ref().to_glib_none().0,
Some(trampoline_pad_task::<F>),
into_raw_pad_task(func),
Some(destroy_closure::<F>),
Some(destroy_closure_pad_task::<F>),
),
"Failed to start pad task",
)
@ -1351,6 +1351,10 @@ fn into_raw_pad_task<F: FnMut() + Send + 'static>(func: F) -> gpointer {
Box::into_raw(func) as gpointer
}
unsafe extern "C" fn destroy_closure_pad_task<F>(ptr: gpointer) {
Box::<RefCell<F>>::from_raw(ptr as *mut _);
}
#[cfg(test)]
mod tests {
use super::*;