forked from mirrors/gstreamer-rs
gstreamer: Use temporary GStr
for the debug category constructors
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1274>
This commit is contained in:
parent
670d8ceec6
commit
a7517cd27b
1 changed files with 12 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::{borrow::Cow, ffi::CStr, fmt, ptr};
|
use std::{borrow::Cow, ffi::CStr, fmt, ptr};
|
||||||
|
|
||||||
use glib::{ffi::gpointer, prelude::*, translate::*, IntoGStr};
|
use glib::{ffi::gpointer, prelude::*, translate::*, IntoGStr, IntoOptionalGStr};
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
@ -75,11 +75,16 @@ impl DebugCategory {
|
||||||
|
|
||||||
// Gets the category if it exists already
|
// Gets the category if it exists already
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = _gst_debug_category_new(
|
let ptr = name.run_with_gstr(|name| {
|
||||||
name.to_glib_none().0,
|
description.run_with_gstr(|description| {
|
||||||
color.into_glib(),
|
_gst_debug_category_new(
|
||||||
description.to_glib_none().0,
|
name.to_glib_none().0,
|
||||||
);
|
color.into_glib(),
|
||||||
|
description.to_glib_none().0,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
// Can be NULL if the debug system is compiled out
|
// Can be NULL if the debug system is compiled out
|
||||||
DebugCategory(ptr::NonNull::new(ptr))
|
DebugCategory(ptr::NonNull::new(ptr))
|
||||||
}
|
}
|
||||||
|
@ -94,7 +99,7 @@ impl DebugCategory {
|
||||||
fn _gst_debug_get_category(name: *const c_char) -> *mut ffi::GstDebugCategory;
|
fn _gst_debug_get_category(name: *const c_char) -> *mut ffi::GstDebugCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cat = _gst_debug_get_category(name.to_glib_none().0);
|
let cat = name.run_with_gstr(|name| _gst_debug_get_category(name.to_glib_none().0));
|
||||||
|
|
||||||
if cat.is_null() {
|
if cat.is_null() {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in a new issue