diff --git a/src/main_context.rs b/src/main_context.rs index 486630da..4790f565 100644 --- a/src/main_context.rs +++ b/src/main_context.rs @@ -13,7 +13,7 @@ use MainContext; use Source; use SourceId; -use source::{CallbackGuard, Priority}; +use source::Priority; impl MainContext { pub fn prepare(&self) -> (bool, i32) { @@ -49,7 +49,6 @@ impl MainContext { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] unsafe extern "C" fn trampoline(func: gpointer) -> gboolean { - let _guard = CallbackGuard::new(); let func: &mut Option> = transmute(func); let func = func.take().expect("MainContext::invoke() closure called multiple times"); func(); @@ -57,7 +56,6 @@ unsafe extern "C" fn trampoline(func: gpointer) -> } unsafe extern "C" fn destroy_closure(ptr: gpointer) { - let _guard = CallbackGuard::new(); Box::>>::from_raw(ptr as *mut _); } diff --git a/src/signal.rs b/src/signal.rs index afd619e8..4b89705a 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -9,7 +9,6 @@ use libc::{c_void, c_uint, c_ulong}; use gobject_ffi::{self, GCallback}; use ffi::{gboolean, GQuark}; use object::{IsA, Object}; -use source::CallbackGuard; use translate::{from_glib, FromGlib, ToGlib, ToGlibPtr}; /// The id of a signal that is returned by `connect`. @@ -89,7 +88,6 @@ pub fn signal_stop_emission_by_name>(instance: &T, signal_name: & } unsafe extern "C" fn destroy_closure(ptr: *mut c_void, _: *mut gobject_ffi::GClosure) { - let _guard = CallbackGuard::new(); // destroy Box::>::from_raw(ptr as *mut _); } diff --git a/src/source.rs b/src/source.rs index e4946068..3f40f709 100644 --- a/src/source.rs +++ b/src/source.rs @@ -54,20 +54,24 @@ impl ToGlib for Continue { /// Unwinding propagation guard. Aborts the process if destroyed while /// panicking. +#[deprecated(note="Rustc has this functionality built-in since 1.24.0")] pub struct CallbackGuard(()); +#[allow(deprecated)] impl CallbackGuard { pub fn new() -> CallbackGuard { CallbackGuard(()) } } +#[allow(deprecated)] impl Default for CallbackGuard { fn default() -> Self { Self::new() } } +#[allow(deprecated)] impl Drop for CallbackGuard { fn drop(&mut self) { use std::io::stderr; @@ -82,13 +86,11 @@ impl Drop for CallbackGuard { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] unsafe extern "C" fn trampoline(func: gpointer) -> gboolean { - let _guard = CallbackGuard::new(); let func: &RefCell Continue + 'static>> = transmute(func); (&mut *func.borrow_mut())().to_glib() } unsafe extern "C" fn destroy_closure(ptr: gpointer) { - let _guard = CallbackGuard::new(); Box:: Continue + 'static>>>::from_raw(ptr as *mut _); } @@ -100,13 +102,11 @@ fn into_raw Continue + Send + 'static>(func: F) -> gpointer { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] unsafe extern "C" fn trampoline_child_watch(pid: u32, status: i32, func: gpointer) { - let _guard = CallbackGuard::new(); let func: &RefCell> = transmute(func); (&mut *func.borrow_mut())(pid, status) } unsafe extern "C" fn destroy_closure_child_watch(ptr: gpointer) { - let _guard = CallbackGuard::new(); Box::>>::from_raw(ptr as *mut _); } diff --git a/src/value.rs b/src/value.rs index b31f04c8..01c9f006 100644 --- a/src/value.rs +++ b/src/value.rs @@ -944,13 +944,11 @@ impl AnyValue { } unsafe extern "C" fn copy(v: *mut c_void) -> *mut c_void { - let _guard = ::source::CallbackGuard::new(); let v = &*(v as *mut AnyValue); Box::into_raw(Box::new(v.clone())) as *mut c_void } unsafe extern "C" fn free(v: *mut c_void) { - let _guard = ::source::CallbackGuard::new(); let _ = Box::from_raw(v as *mut AnyValue); } } @@ -1021,13 +1019,11 @@ impl AnySendValue { } unsafe extern "C" fn copy(v: *mut c_void) -> *mut c_void { - let _guard = ::source::CallbackGuard::new(); let v = &*(v as *mut AnySendValue); Box::into_raw(Box::new(v.clone())) as *mut c_void } unsafe extern "C" fn free(v: *mut c_void) { - let _guard = ::source::CallbackGuard::new(); let _ = Box::from_raw(v as *mut AnySendValue); } }