mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 00:26:31 +00:00
gstreamer: Use temporary GStr
for the debug category constructors
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1263>
This commit is contained in:
parent
4384934b32
commit
074a2b1578
1 changed files with 12 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
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 once_cell::sync::Lazy;
|
||||
|
||||
|
@ -75,11 +75,16 @@ impl DebugCategory {
|
|||
|
||||
// Gets the category if it exists already
|
||||
unsafe {
|
||||
let ptr = _gst_debug_category_new(
|
||||
name.to_glib_none().0,
|
||||
color.into_glib(),
|
||||
description.to_glib_none().0,
|
||||
);
|
||||
let ptr = name.run_with_gstr(|name| {
|
||||
description.run_with_gstr(|description| {
|
||||
_gst_debug_category_new(
|
||||
name.to_glib_none().0,
|
||||
color.into_glib(),
|
||||
description.to_glib_none().0,
|
||||
)
|
||||
})
|
||||
});
|
||||
|
||||
// Can be NULL if the debug system is compiled out
|
||||
DebugCategory(ptr::NonNull::new(ptr))
|
||||
}
|
||||
|
@ -94,7 +99,7 @@ impl DebugCategory {
|
|||
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() {
|
||||
None
|
||||
|
|
Loading…
Reference in a new issue