From b1a0764b92b396d145416df909c67f0ff28e031f Mon Sep 17 00:00:00 2001 From: Evgenii Pashkin Date: Fri, 2 Mar 2018 22:09:19 +0300 Subject: [PATCH] Revert "Remove callback_guard" --- gir | 2 +- src/auto/enums.rs | 2 +- src/auto/flags.rs | 2 +- src/auto/mod.rs | 2 +- src/auto/pixbuf.rs | 11 ++++++++++- src/auto/pixbuf_format.rs | 2 +- src/auto/pixbuf_loader.rs | 6 +++++- src/auto/pixbuf_simple_anim.rs | 3 ++- src/lib.rs | 3 +++ src/pixbuf.rs | 3 +++ src/rt.rs | 17 +++++++++++++++++ 11 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/rt.rs diff --git a/gir b/gir index 8b9d0bb3..fbb95f48 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit 8b9d0bb32ed3b76ff9931ee283c07d32af955b60 +Subproject commit fbb95f484ed5f202af9594b6c8d4f59fc0501bf1 diff --git a/src/auto/enums.rs b/src/auto/enums.rs index 2f53bc69..cdac5cb1 100644 --- a/src/auto/enums.rs +++ b/src/auto/enums.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb) +// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT diff --git a/src/auto/flags.rs b/src/auto/flags.rs index 7274e5e4..e93d9188 100644 --- a/src/auto/flags.rs +++ b/src/auto/flags.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb) +// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT diff --git a/src/auto/mod.rs b/src/auto/mod.rs index 498d67bc..02e6afa9 100644 --- a/src/auto/mod.rs +++ b/src/auto/mod.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb) +// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT diff --git a/src/auto/pixbuf.rs b/src/auto/pixbuf.rs index d731a067..b920b11f 100644 --- a/src/auto/pixbuf.rs +++ b/src/auto/pixbuf.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb) +// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT @@ -513,54 +513,63 @@ impl + IsA> PixbufExt for O { unsafe extern "C" fn notify_bits_per_sample_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_colorspace_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_has_alpha_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_height_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_n_channels_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_pixel_bytes_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_pixels_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_rowstride_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn notify_width_trampoline

(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&Pixbuf::from_glib_borrow(this).downcast_unchecked()) } diff --git a/src/auto/pixbuf_format.rs b/src/auto/pixbuf_format.rs index e491f0f4..29edf6d8 100644 --- a/src/auto/pixbuf_format.rs +++ b/src/auto/pixbuf_format.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb) +// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT diff --git a/src/auto/pixbuf_loader.rs b/src/auto/pixbuf_loader.rs index 608d218b..199772e2 100644 --- a/src/auto/pixbuf_loader.rs +++ b/src/auto/pixbuf_loader.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb) +// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT @@ -170,24 +170,28 @@ impl + IsA> PixbufLoaderExt for O { unsafe extern "C" fn area_prepared_trampoline

(this: *mut ffi::GdkPixbufLoader, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&PixbufLoader::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn area_updated_trampoline

(this: *mut ffi::GdkPixbufLoader, x: libc::c_int, y: libc::c_int, width: libc::c_int, height: libc::c_int, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P, i32, i32, i32, i32) + 'static) = transmute(f); f(&PixbufLoader::from_glib_borrow(this).downcast_unchecked(), x, y, width, height) } unsafe extern "C" fn closed_trampoline

(this: *mut ffi::GdkPixbufLoader, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&PixbufLoader::from_glib_borrow(this).downcast_unchecked()) } unsafe extern "C" fn size_prepared_trampoline

(this: *mut ffi::GdkPixbufLoader, width: libc::c_int, height: libc::c_int, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P, i32, i32) + 'static) = transmute(f); f(&PixbufLoader::from_glib_borrow(this).downcast_unchecked(), width, height) } diff --git a/src/auto/pixbuf_simple_anim.rs b/src/auto/pixbuf_simple_anim.rs index 30eb1b1f..c891b76c 100644 --- a/src/auto/pixbuf_simple_anim.rs +++ b/src/auto/pixbuf_simple_anim.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb) +// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT @@ -74,6 +74,7 @@ impl + IsA> PixbufSimpleAnimExt f unsafe extern "C" fn notify_loop_trampoline

(this: *mut ffi::GdkPixbufSimpleAnim, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) where P: IsA { + callback_guard!(); let f: &&(Fn(&P) + 'static) = transmute(f); f(&PixbufSimpleAnim::from_glib_borrow(this).downcast_unchecked()) } diff --git a/src/lib.rs b/src/lib.rs index 1af32d32..18281d41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,9 @@ pub use glib::{ Value, }; +#[macro_use] +mod rt; + mod auto; mod animation; diff --git a/src/pixbuf.rs b/src/pixbuf.rs index 1a82f1e3..8b7e288c 100644 --- a/src/pixbuf.rs +++ b/src/pixbuf.rs @@ -104,6 +104,7 @@ impl Pixbuf { let user_data: Box> = Box::new(Box::new(callback)); unsafe extern "C" fn new_from_stream_async_trampoline) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) { + callback_guard!(); let mut error = ptr::null_mut(); let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error); let result = if error.is_null() { @@ -126,6 +127,7 @@ impl Pixbuf { let user_data: Box> = Box::new(Box::new(callback)); unsafe extern "C" fn new_from_stream_at_scale_async_trampoline) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) { + callback_guard!(); let mut error = ptr::null_mut(); let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error); let result = if error.is_null() { @@ -185,6 +187,7 @@ impl Pixbuf { let user_data: Box> = Box::new(Box::new(callback)); unsafe extern "C" fn get_file_info_async_trampoline, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) { + callback_guard!(); let mut error = ptr::null_mut(); let mut width = mem::uninitialized(); let mut height = mem::uninitialized(); diff --git a/src/rt.rs b/src/rt.rs new file mode 100644 index 00000000..7d499d02 --- /dev/null +++ b/src/rt.rs @@ -0,0 +1,17 @@ +// Copyright 2013-2017, The Gtk-rs Project Developers. +// See the COPYRIGHT file at the top-level directory of this distribution. +// Licensed under the MIT license, see the LICENSE file or + + +macro_rules! assert_initialized_main_thread { + () => () +} + +macro_rules! callback_guard { + () => ( + let _guard = ::glib::CallbackGuard::new(); + if cfg!(debug_assertions) { + assert_initialized_main_thread!(); + } + ) +}