Add helper function that allows to catch panics and poison the element

This commit is contained in:
Sebastian Dröge 2017-12-04 21:30:10 +02:00
parent b3725312c4
commit 083371866a

View file

@ -102,6 +102,11 @@ pub unsafe trait ElementBase: IsA<gst::Element> + ObjectType {
.unwrap_or(()) .unwrap_or(())
} }
} }
fn catch_panic<F: FnOnce(&Self) -> T, T>(&self, fallback: T, f: F) -> T {
let panicked = unsafe { &(*self.get_instance()).panicked };
panic_to_error!(self, panicked, fallback, { f(self) })
}
} }
pub unsafe trait ElementClassExt<T: ElementBase> pub unsafe trait ElementClassExt<T: ElementBase>