Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit c0c520f

Browse files
committed
Regenerate with latest gir
1 parent c87b143 commit c0c520f

File tree

9 files changed

+59
-20
lines changed

9 files changed

+59
-20
lines changed

atk/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

atk/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

gdk/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

gdk/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

gdkx11/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

gdkx11/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

gtk/src/auto/icon_info.rs

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,25 @@ impl IconInfo {
7171
}
7272

7373
#[doc(alias = "gtk_icon_info_load_icon_async")]
74-
pub fn load_icon_async<P: FnOnce(Result<gdk_pixbuf::Pixbuf, glib::Error>) + Send + 'static>(
74+
pub fn load_icon_async<P: FnOnce(Result<gdk_pixbuf::Pixbuf, glib::Error>) + 'static>(
7575
&self,
7676
cancellable: Option<&impl IsA<gio::Cancellable>>,
7777
callback: P,
7878
) {
79-
let user_data: Box_<P> = Box_::new(callback);
79+
let main_context = glib::MainContext::ref_thread_default();
80+
let is_main_context_owner = main_context.is_owner();
81+
let has_acquired_main_context = (!is_main_context_owner)
82+
.then(|| main_context.acquire().ok())
83+
.flatten();
84+
assert!(
85+
is_main_context_owner || has_acquired_main_context.is_some(),
86+
"Async operations only allowed if the thread is owning the MainContext"
87+
);
88+
89+
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
90+
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
8091
unsafe extern "C" fn load_icon_async_trampoline<
81-
P: FnOnce(Result<gdk_pixbuf::Pixbuf, glib::Error>) + Send + 'static,
92+
P: FnOnce(Result<gdk_pixbuf::Pixbuf, glib::Error>) + 'static,
8293
>(
8394
_source_object: *mut glib::gobject_ffi::GObject,
8495
res: *mut gio::ffi::GAsyncResult,
@@ -92,7 +103,9 @@ impl IconInfo {
92103
} else {
93104
Err(from_glib_full(error))
94105
};
95-
let callback: Box_<P> = Box_::from_raw(user_data as *mut _);
106+
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
107+
Box_::from_raw(user_data as *mut _);
108+
let callback: P = callback.into_inner();
96109
callback(result);
97110
}
98111
let callback = load_icon_async_trampoline::<P>;
@@ -169,7 +182,7 @@ impl IconInfo {
169182

170183
#[doc(alias = "gtk_icon_info_load_symbolic_async")]
171184
pub fn load_symbolic_async<
172-
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + Send + 'static,
185+
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + 'static,
173186
>(
174187
&self,
175188
fg: &gdk::RGBA,
@@ -179,9 +192,20 @@ impl IconInfo {
179192
cancellable: Option<&impl IsA<gio::Cancellable>>,
180193
callback: P,
181194
) {
182-
let user_data: Box_<P> = Box_::new(callback);
195+
let main_context = glib::MainContext::ref_thread_default();
196+
let is_main_context_owner = main_context.is_owner();
197+
let has_acquired_main_context = (!is_main_context_owner)
198+
.then(|| main_context.acquire().ok())
199+
.flatten();
200+
assert!(
201+
is_main_context_owner || has_acquired_main_context.is_some(),
202+
"Async operations only allowed if the thread is owning the MainContext"
203+
);
204+
205+
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
206+
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
183207
unsafe extern "C" fn load_symbolic_async_trampoline<
184-
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + Send + 'static,
208+
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + 'static,
185209
>(
186210
_source_object: *mut glib::gobject_ffi::GObject,
187211
res: *mut gio::ffi::GAsyncResult,
@@ -201,7 +225,9 @@ impl IconInfo {
201225
} else {
202226
Err(from_glib_full(error))
203227
};
204-
let callback: Box_<P> = Box_::from_raw(user_data as *mut _);
228+
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
229+
Box_::from_raw(user_data as *mut _);
230+
let callback: P = callback.into_inner();
205231
callback(result);
206232
}
207233
let callback = load_symbolic_async_trampoline::<P>;
@@ -274,16 +300,27 @@ impl IconInfo {
274300

275301
#[doc(alias = "gtk_icon_info_load_symbolic_for_context_async")]
276302
pub fn load_symbolic_for_context_async<
277-
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + Send + 'static,
303+
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + 'static,
278304
>(
279305
&self,
280306
context: &impl IsA<StyleContext>,
281307
cancellable: Option<&impl IsA<gio::Cancellable>>,
282308
callback: P,
283309
) {
284-
let user_data: Box_<P> = Box_::new(callback);
310+
let main_context = glib::MainContext::ref_thread_default();
311+
let is_main_context_owner = main_context.is_owner();
312+
let has_acquired_main_context = (!is_main_context_owner)
313+
.then(|| main_context.acquire().ok())
314+
.flatten();
315+
assert!(
316+
is_main_context_owner || has_acquired_main_context.is_some(),
317+
"Async operations only allowed if the thread is owning the MainContext"
318+
);
319+
320+
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
321+
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
285322
unsafe extern "C" fn load_symbolic_for_context_async_trampoline<
286-
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + Send + 'static,
323+
P: FnOnce(Result<(gdk_pixbuf::Pixbuf, bool), glib::Error>) + 'static,
287324
>(
288325
_source_object: *mut glib::gobject_ffi::GObject,
289326
res: *mut gio::ffi::GAsyncResult,
@@ -303,7 +340,9 @@ impl IconInfo {
303340
} else {
304341
Err(from_glib_full(error))
305342
};
306-
let callback: Box_<P> = Box_::from_raw(user_data as *mut _);
343+
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
344+
Box_::from_raw(user_data as *mut _);
345+
let callback: P = callback.into_inner();
307346
callback(result);
308347
}
309348
let callback = load_symbolic_for_context_async_trampoline::<P>;

gtk/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

gtk/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ ee37253c10af)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 5264fd0c3183)

0 commit comments

Comments
 (0)