Use glib::Error::into_raw() for passing GErrors without copying back to C

This commit is contained in:
Sebastian Dröge 2021-04-11 10:28:06 +03:00
parent 1609a7c923
commit a775f58753
2 changed files with 2 additions and 8 deletions

View file

@ -3,16 +3,10 @@
use crate::WebRTCDataChannel; use crate::WebRTCDataChannel;
use glib::translate::*; use glib::translate::*;
use std::mem;
impl WebRTCDataChannel { impl WebRTCDataChannel {
pub fn on_error(&self, error: glib::Error) { pub fn on_error(&self, error: glib::Error) {
let error = mem::ManuallyDrop::new(error);
unsafe { unsafe {
ffi::gst_webrtc_data_channel_on_error( ffi::gst_webrtc_data_channel_on_error(self.to_glib_none().0, error.into_raw());
self.to_glib_none().0,
mut_override(error.to_glib_none().0),
);
} }
} }
} }

View file

@ -146,7 +146,7 @@ unsafe extern "C" fn uri_handler_set_uri<T: URIHandlerImpl>(
) { ) {
Ok(()) => true.to_glib(), Ok(()) => true.to_glib(),
Err(error) => { Err(error) => {
*err = error.to_glib_full() as *mut _; *err = error.into_raw();
false.to_glib() false.to_glib()
} }
} }