gl: Mark other_context in GLDisplay::create_context() as nullable

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/438

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1207>
This commit is contained in:
Sebastian Dröge 2023-01-27 16:29:49 +02:00
parent 01bbb07744
commit 5f05f7ec05
2 changed files with 12 additions and 4 deletions

View file

@ -341,6 +341,12 @@ status = "generate"
# glib::Thread not found in `glib` # glib::Thread not found in `glib`
ignore = true ignore = true
[[object.function]]
name = "create_context"
[[object.function.parameter]]
name = "other_context"
nullable = true
[[object.function]] [[object.function]]
name = "add_context" name = "add_context"
[object.function.return] [object.function.return]

View file

@ -53,8 +53,10 @@ pub trait GLDisplayExt: 'static {
fn add_context(&self, context: &impl IsA<GLContext>) -> Result<(), glib::error::BoolError>; fn add_context(&self, context: &impl IsA<GLContext>) -> Result<(), glib::error::BoolError>;
#[doc(alias = "gst_gl_display_create_context")] #[doc(alias = "gst_gl_display_create_context")]
fn create_context(&self, other_context: &impl IsA<GLContext>) fn create_context(
-> Result<GLContext, glib::Error>; &self,
other_context: Option<&impl IsA<GLContext>>,
) -> Result<GLContext, glib::Error>;
#[doc(alias = "gst_gl_display_create_window")] #[doc(alias = "gst_gl_display_create_window")]
fn create_window(&self) -> Result<GLWindow, glib::BoolError>; fn create_window(&self) -> Result<GLWindow, glib::BoolError>;
@ -111,14 +113,14 @@ impl<O: IsA<GLDisplay>> GLDisplayExt for O {
fn create_context( fn create_context(
&self, &self,
other_context: &impl IsA<GLContext>, other_context: Option<&impl IsA<GLContext>>,
) -> Result<GLContext, glib::Error> { ) -> Result<GLContext, glib::Error> {
unsafe { unsafe {
let mut p_context = ptr::null_mut(); let mut p_context = ptr::null_mut();
let mut error = ptr::null_mut(); let mut error = ptr::null_mut();
let is_ok = ffi::gst_gl_display_create_context( let is_ok = ffi::gst_gl_display_create_context(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
other_context.as_ref().to_glib_none().0, other_context.map(|p| p.as_ref()).to_glib_none().0,
&mut p_context, &mut p_context,
&mut error, &mut error,
); );