Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit b1a0764

Browse files
committed
Revert "Remove callback_guard"
1 parent 2aba23c commit b1a0764

File tree

11 files changed

+45
-8
lines changed

11 files changed

+45
-8
lines changed

src/auto/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

src/auto/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

src/auto/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

src/auto/pixbuf.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

@@ -513,54 +513,63 @@ impl<O: IsA<Pixbuf> + IsA<glib::object::Object>> PixbufExt for O {
513513

514514
unsafe extern "C" fn notify_bits_per_sample_trampoline<P>(this: *mut ffi::GdkPixbuf, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
515515
where P: IsA<Pixbuf> {
516+
callback_guard!();
516517
let f: &&(Fn(&P) + 'static) = transmute(f);
517518
f(&Pixbuf::from_glib_borrow(this).downcast_unchecked())
518519
}
519520

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

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

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

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

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

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

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

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

src/auto/pixbuf_format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

src/auto/pixbuf_loader.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

@@ -170,24 +170,28 @@ impl<O: IsA<PixbufLoader> + IsA<glib::object::Object>> PixbufLoaderExt for O {
170170

171171
unsafe extern "C" fn area_prepared_trampoline<P>(this: *mut ffi::GdkPixbufLoader, f: glib_ffi::gpointer)
172172
where P: IsA<PixbufLoader> {
173+
callback_guard!();
173174
let f: &&(Fn(&P) + 'static) = transmute(f);
174175
f(&PixbufLoader::from_glib_borrow(this).downcast_unchecked())
175176
}
176177

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

183185
unsafe extern "C" fn closed_trampoline<P>(this: *mut ffi::GdkPixbufLoader, f: glib_ffi::gpointer)
184186
where P: IsA<PixbufLoader> {
187+
callback_guard!();
185188
let f: &&(Fn(&P) + 'static) = transmute(f);
186189
f(&PixbufLoader::from_glib_borrow(this).downcast_unchecked())
187190
}
188191

189192
unsafe extern "C" fn size_prepared_trampoline<P>(this: *mut ffi::GdkPixbufLoader, width: libc::c_int, height: libc::c_int, f: glib_ffi::gpointer)
190193
where P: IsA<PixbufLoader> {
194+
callback_guard!();
191195
let f: &&(Fn(&P, i32, i32) + 'static) = transmute(f);
192196
f(&PixbufLoader::from_glib_borrow(this).downcast_unchecked(), width, height)
193197
}

src/auto/pixbuf_simple_anim.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 8b9d0bb)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
22
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
33
// DO NOT EDIT
44

@@ -74,6 +74,7 @@ impl<O: IsA<PixbufSimpleAnim> + IsA<glib::object::Object>> PixbufSimpleAnimExt f
7474

7575
unsafe extern "C" fn notify_loop_trampoline<P>(this: *mut ffi::GdkPixbufSimpleAnim, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
7676
where P: IsA<PixbufSimpleAnim> {
77+
callback_guard!();
7778
let f: &&(Fn(&P) + 'static) = transmute(f);
7879
f(&PixbufSimpleAnim::from_glib_borrow(this).downcast_unchecked())
7980
}

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub use glib::{
2424
Value,
2525
};
2626

27+
#[macro_use]
28+
mod rt;
29+
2730
mod auto;
2831

2932
mod animation;

src/pixbuf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl Pixbuf {
104104
let user_data: Box<Box<R>> = Box::new(Box::new(callback));
105105
unsafe extern "C" fn new_from_stream_async_trampoline<R: FnOnce(Result<Pixbuf, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
106106
{
107+
callback_guard!();
107108
let mut error = ptr::null_mut();
108109
let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error);
109110
let result = if error.is_null() {
@@ -126,6 +127,7 @@ impl Pixbuf {
126127
let user_data: Box<Box<R>> = Box::new(Box::new(callback));
127128
unsafe extern "C" fn new_from_stream_at_scale_async_trampoline<R: FnOnce(Result<Pixbuf, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
128129
{
130+
callback_guard!();
129131
let mut error = ptr::null_mut();
130132
let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error);
131133
let result = if error.is_null() {
@@ -185,6 +187,7 @@ impl Pixbuf {
185187
let user_data: Box<Box<Q>> = Box::new(Box::new(callback));
186188
unsafe extern "C" fn get_file_info_async_trampoline<Q: FnOnce(Result<Option<(PixbufFormat, i32, i32)>, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
187189
{
190+
callback_guard!();
188191
let mut error = ptr::null_mut();
189192
let mut width = mem::uninitialized();
190193
let mut height = mem::uninitialized();

src/rt.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013-2017, The Gtk-rs Project Developers.
2+
// See the COPYRIGHT file at the top-level directory of this distribution.
3+
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4+
5+
6+
macro_rules! assert_initialized_main_thread {
7+
() => ()
8+
}
9+
10+
macro_rules! callback_guard {
11+
() => (
12+
let _guard = ::glib::CallbackGuard::new();
13+
if cfg!(debug_assertions) {
14+
assert_initialized_main_thread!();
15+
}
16+
)
17+
}

0 commit comments

Comments
 (0)