mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-26 21:41:03 +00:00
Add helper function that allows to catch panics and poison the element
This commit is contained in:
parent
b3725312c4
commit
083371866a
1 changed files with 5 additions and 0 deletions
|
@ -102,6 +102,11 @@ pub unsafe trait ElementBase: IsA<gst::Element> + ObjectType {
|
|||
.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>
|
||||
|
|
Loading…
Reference in a new issue