Skip to content

Commit 49f78b3

Browse files
committed
Use IntoGlibPtr instead of to_glib_full() in more places
Fixes #872
1 parent 85e2582 commit 49f78b3

File tree

8 files changed

+22
-19
lines changed

8 files changed

+22
-19
lines changed

gdk-pixbuf/src/subclass/pixbuf_animation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,5 @@ unsafe extern "C" fn animation_get_iter<T: PixbufAnimationImpl>(
164164
let total = Duration::from_secs((*start_time_ptr).tv_sec.try_into().unwrap())
165165
+ Duration::from_micros((*start_time_ptr).tv_usec.try_into().unwrap());
166166

167-
imp.iter(total).to_glib_full()
167+
imp.iter(total).into_glib_ptr()
168168
}

gio/src/dbus_connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl DBusConnection {
207207
let incoming = from_glib(incoming);
208208
let callback: &P = &*(user_data as *mut _);
209209
let res = (*callback)(&connection, &message, incoming);
210-
res.to_glib_full()
210+
res.into_glib_ptr()
211211
}
212212
let filter_function = Some(filter_function_func::<P> as _);
213213
unsafe extern "C" fn user_data_free_func_func<

gio/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a> BindingBuilder<'a> {
118118
let user_data = &*(user_data as *const Mappings);
119119
let f = user_data.1.as_ref().unwrap();
120120
let value = &*(value as *const glib::Value);
121-
f(value, from_glib_none(variant_type)).to_glib_full()
121+
f(value, from_glib_none(variant_type)).into_glib_ptr()
122122
}
123123
unsafe extern "C" fn destroy_closure(ptr: *mut libc::c_void) {
124124
let _ = Box::<Mappings>::from_raw(ptr as *mut _);

gio/src/subclass/action_group.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ unsafe extern "C" fn action_group_get_action_parameter_type<T: ActionGroupImpl>(
432432
let ret = imp.action_parameter_type(&action_name);
433433

434434
if let Some(param_type) = ret {
435-
let param_type = param_type.to_glib_full();
435+
let param_type = param_type.into_glib_ptr();
436436
wrap.set_qdata(
437437
*ACTION_GROUP_GET_ACTION_PARAMETER_QUARK,
438438
PtrHolder(param_type, |ptr| glib::ffi::g_free(ptr as *mut _)),
@@ -458,7 +458,7 @@ unsafe extern "C" fn action_group_get_action_state_type<T: ActionGroupImpl>(
458458

459459
if let Some(state_type) = ret {
460460
let instance = imp.obj();
461-
let state_type = state_type.to_glib_full();
461+
let state_type = state_type.into_glib_ptr();
462462
instance.set_qdata(
463463
*ACTION_GROUP_GET_ACTION_STATE_TYPE_QUARK,
464464
PtrHolder(state_type, |ptr| glib::ffi::g_free(ptr as *mut _)),
@@ -483,7 +483,7 @@ unsafe extern "C" fn action_group_get_action_state_hint<T: ActionGroupImpl>(
483483
let ret = imp.action_state_hint(&action_name);
484484
if let Some(state_hint) = ret {
485485
let instance = imp.obj();
486-
let state_hint_ptr = state_hint.to_glib_full();
486+
let state_hint_ptr = state_hint.into_glib_ptr();
487487
instance.set_qdata(
488488
*ACTION_GROUP_GET_ACTION_STATE_HINT_QUARK,
489489
PtrHolder(state_hint_ptr, |ptr| glib::ffi::g_variant_unref(ptr)),
@@ -507,7 +507,7 @@ unsafe extern "C" fn action_group_get_action_state<T: ActionGroupImpl>(
507507
let ret = imp.action_state(&action_name);
508508
if let Some(state) = ret {
509509
let instance = imp.obj();
510-
let state_ptr = state.to_glib_full();
510+
let state_ptr = state.into_glib_ptr();
511511
instance.set_qdata(
512512
*ACTION_GROUP_GET_ACTION_STATE_QUARK,
513513
PtrHolder(state_ptr, |ptr| glib::ffi::g_variant_unref(ptr)),
@@ -644,7 +644,7 @@ unsafe extern "C" fn action_group_query_action<T: ActionGroupImpl>(
644644
}
645645
if !parameter_type.is_null() {
646646
if let Some(rs_parameter_type) = rs_parameter_type {
647-
let ret = rs_parameter_type.to_glib_full();
647+
let ret = rs_parameter_type.into_glib_ptr();
648648
instance.set_qdata(
649649
*ACTION_GROUP_QUERY_ACTION_PARAM_TYPE_QUARK,
650650
PtrHolder(ret, |ptr| glib::ffi::g_free(ptr as *mut _)),
@@ -656,7 +656,7 @@ unsafe extern "C" fn action_group_query_action<T: ActionGroupImpl>(
656656
}
657657
if !state_type.is_null() {
658658
if let Some(rs_state_type) = rs_state_type {
659-
let ret = rs_state_type.to_glib_full();
659+
let ret = rs_state_type.into_glib_ptr();
660660
instance.set_qdata(
661661
*ACTION_GROUP_QUERY_ACTION_STATE_TYPE_QUARK,
662662
PtrHolder(ret, |ptr| glib::ffi::g_free(ptr as *mut _)),
@@ -668,7 +668,7 @@ unsafe extern "C" fn action_group_query_action<T: ActionGroupImpl>(
668668
}
669669
if !state_hint.is_null() {
670670
if let Some(rs_state_hint) = rs_state_hint {
671-
let ret = rs_state_hint.to_glib_full();
671+
let ret = rs_state_hint.into_glib_ptr();
672672
instance.set_qdata(
673673
*ACTION_GROUP_QUERY_ACTION_STATE_HINT_QUARK,
674674
PtrHolder(ret, |ptr| glib::ffi::g_variant_unref(ptr)),
@@ -680,7 +680,7 @@ unsafe extern "C" fn action_group_query_action<T: ActionGroupImpl>(
680680
}
681681
if !state.is_null() {
682682
if let Some(rs_state) = rs_state {
683-
let ret = rs_state.to_glib_full();
683+
let ret = rs_state.into_glib_ptr();
684684
instance.set_qdata(
685685
*ACTION_GROUP_QUERY_ACTION_STATE_QUARK,
686686
PtrHolder(ret, |ptr| glib::ffi::g_variant_unref(ptr)),

gio/src/subclass/list_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ where
142142
type_.name()
143143
);
144144
};
145-
item.to_glib_full()
145+
item.into_glib_ptr()
146146
}

gio/src/task.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ glib::wrapper! {
6161

6262
macro_rules! task_impl {
6363
($name:ident $(, @bound: $bound:tt)? $(, @safety: $safety:tt)?) => {
64-
impl <V: ValueType $(+ $bound)?> $name<V> {
64+
impl <V: Into<glib::Value> + ValueType $(+ $bound)?> $name<V> {
6565
#[doc(alias = "g_task_new")]
6666
#[allow(unused_unsafe)]
6767
pub unsafe fn new<S, P, Q>(
@@ -260,14 +260,15 @@ macro_rules! task_impl {
260260
},
261261
#[cfg(not(feature = "v2_64"))]
262262
Ok(v) => unsafe {
263+
let v: glib::Value = v.into();
263264
ffi::g_task_return_pointer(
264265
self.to_glib_none().0,
265-
v.to_value().to_glib_full() as *mut _,
266+
<glib::Value as glib::translate::IntoGlibPtr::<*mut glib::gobject_ffi::GValue>>::into_glib_ptr(v) as glib::ffi::gpointer,
266267
Some(value_free),
267268
)
268269
},
269270
Err(e) => unsafe {
270-
ffi::g_task_return_error(self.to_glib_none().0, e.to_glib_full() as *mut _);
271+
ffi::g_task_return_error(self.to_glib_none().0, e.into_glib_ptr());
271272
},
272273
}
273274
}

glib/src/param_spec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl ParamSpec {
118118
pub fn downcast<T: ParamSpecType>(self) -> Result<T, ParamSpec> {
119119
unsafe {
120120
if self.type_() == T::static_type() {
121-
Ok(from_glib_full(self.to_glib_full()))
121+
Ok(from_glib_full(self.into_glib_ptr()))
122122
} else {
123123
Err(self)
124124
}
@@ -497,7 +497,7 @@ macro_rules! define_param_spec {
497497
#[inline]
498498
pub fn upcast(self) -> ParamSpec {
499499
unsafe {
500-
from_glib_full(ToGlibPtr::<*const $ffi_type>::to_glib_full(&self) as *mut gobject_ffi::GParamSpec)
500+
from_glib_full(IntoGlibPtr::<*mut $ffi_type>::into_glib_ptr(self) as *mut gobject_ffi::GParamSpec)
501501
}
502502
}
503503

pango/src/attribute.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ impl Attribute {
5454
pub fn downcast<T: IsAttribute>(self) -> Result<T, Attribute> {
5555
unsafe {
5656
if T::ATTR_TYPES.contains(&self.attr_class().type_()) {
57-
Ok(from_glib_full(self.to_glib_full()))
57+
Ok(from_glib_full(glib::translate::IntoGlibPtr::<
58+
*mut ffi::PangoAttribute,
59+
>::into_glib_ptr(self)))
5860
} else {
5961
Err(self)
6062
}
@@ -140,7 +142,7 @@ macro_rules! define_attribute_struct {
140142

141143
#[inline]
142144
fn upcast(self) -> crate::Attribute {
143-
unsafe { glib::translate::from_glib_full(glib::translate::ToGlibPtr::to_glib_full(&self) as *mut ffi::PangoAttribute) }
145+
unsafe { glib::translate::from_glib_full(glib::translate::IntoGlibPtr::<*mut $ffi_type>::into_glib_ptr(self) as *mut ffi::PangoAttribute) }
144146
}
145147

146148
#[inline]

0 commit comments

Comments
 (0)