From b941e9c56a7d680e75c08f0dd2de725fe66bda51 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 8 Nov 2024 17:54:15 -0300 Subject: [PATCH] validate: Action.structure is nullable Part-of: --- gstreamer-validate/src/action.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gstreamer-validate/src/action.rs b/gstreamer-validate/src/action.rs index 35d4d296d..35b0b3d98 100644 --- a/gstreamer-validate/src/action.rs +++ b/gstreamer-validate/src/action.rs @@ -12,19 +12,27 @@ gst::mini_object_wrapper!(Action, ActionRef, ffi::GstValidateAction, || { }); impl ActionRef { - pub fn structure(&self) -> &gst::StructureRef { + pub fn structure(&self) -> Option<&gst::StructureRef> { unsafe { let action = &self.0 as *const ffi::GstValidateAction; - gst::StructureRef::from_glib_borrow((*action).structure) + if (*action).structure.is_null() { + None + } else { + Some(gst::StructureRef::from_glib_borrow((*action).structure)) + } } } - pub fn structure_mut(&mut self) -> &mut gst::StructureRef { + pub fn structure_mut(&mut self) -> Option<&mut gst::StructureRef> { unsafe { let action = &mut self.0 as *mut ffi::GstValidateAction; - gst::StructureRef::from_glib_borrow_mut((*action).structure) + if (*action).structure.is_null() { + None + } else { + Some(gst::StructureRef::from_glib_borrow_mut((*action).structure)) + } } }