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

Commit 176a97a

Browse files
authored
Merge pull request #726 from sdroege/0.15-backports
0.15 backports
2 parents 38ea6ae + 922f5a4 commit 176a97a

File tree

21 files changed

+71
-32
lines changed

21 files changed

+71
-32
lines changed

atk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "atk"
77
homepage = "https://gtk-rs.org/"
88
authors = ["The gtk-rs Project Developers"]
99
readme = "README.md"
10-
version = "0.15.2"
10+
version = "0.15.3"
1111
keywords = ["atk", "gtk-rs", "gnome", "accessibility"]
1212
repository = "https://github.com/gtk-rs/gtk3-rs"
1313
exclude = [

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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ license = "MIT"
4040
links = "atk-1.0"
4141
name = "atk-sys"
4242
repository = "https://github.com/gtk-rs/gtk3-rs"
43-
version = "0.15.2"
43+
version = "0.15.3"
4444
edition = "2021"
4545
rust-version = "1.56"
4646
[package.metadata.docs.rs]

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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["The gtk-rs Project Developers"]
66
keywords = ["gdk", "gtk", "gtk-rs", "gnome", "GUI"]
77
readme = "README.md"
88
documentation = "https://gtk-rs.org/gtk3-rs/stable/latest/docs/gdk/"
9-
version = "0.15.2"
9+
version = "0.15.3"
1010
description = "Rust bindings for the GDK 3 library"
1111
repository = "https://github.com/gtk-rs/gtk3-rs"
1212
exclude = [

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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ license = "MIT"
6464
links = "gdk-3"
6565
name = "gdk-sys"
6666
repository = "https://github.com/gtk-rs/gtk3-rs"
67-
version = "0.15.2"
67+
version = "0.15.3"
6868
edition = "2021"
6969
rust-version = "1.56"
7070
[package.metadata.docs.rs]

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)

gdkwayland/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "MIT"
99
name = "gdkwayland"
1010
readme = "README.md"
1111
repository = "https://github.com/gtk-rs/gtk3-rs"
12-
version = "0.15.2"
12+
version = "0.15.3"
1313
rust-version = "1.56"
1414

1515
[features]

gdkwayland/sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = ["gdk", "ffi", "gtk-rs", "gnome"]
66
license = "MIT"
77
name = "gdkwayland-sys"
88
repository = "https://github.com/gtk-rs/gtk3-rs"
9-
version = "0.15.2"
9+
version = "0.15.3"
1010
edition = "2021"
1111
rust-version = "1.56"
1212

gdkx11/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["The gtk-rs Project Developers"]
66
keywords = ["gdkx11", "gdk", "gtk-rs", "gnome", "GUI"]
77
readme = "README.md"
88
documentation = "https://gtk-rs.org/gtk3-rs/stable/latest/docs/gdkx11/"
9-
version = "0.15.2"
9+
version = "0.15.3"
1010
description = "Rust bindings for the GDK X11 library"
1111
repository = "https://github.com/gtk-rs/gtk3-rs"
1212
exclude = [

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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = ["gdkx11", "ffi", "gtk-rs", "gnome"]
66
license = "MIT"
77
repository = "https://github.com/gtk-rs/gtk3-rs"
88
name = "gdkx11-sys"
9-
version = "0.15.2"
9+
version = "0.15.3"
1010
build = "build.rs"
1111
edition = "2021"
1212
rust-version = "1.56"

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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "gtk"
77
homepage = "https://gtk-rs.org/"
88
authors = ["The gtk-rs Project Developers"]
99
readme = "README.md"
10-
version = "0.15.2"
10+
version = "0.15.3"
1111
keywords = ["gtk", "gtk-rs", "gnome", "GUI"]
1212
repository = "https://github.com/gtk-rs/gtk3-rs"
1313
build = "build.rs"

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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gtk-sys"
3-
version = "0.15.2"
3+
version = "0.15.3"
44
links = "gtk-3"
55
build = "build.rs"
66
authors = ["The gtk-rs Project Developers"]

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)

gtk3-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = "MIT"
55
description = "Rust bindings for the GTK 3 library"
66
homepage = "https://gtk-rs.org/"
77
name = "gtk3-macros"
8-
version = "0.15.2"
8+
version = "0.15.3"
99
authors = ["The gtk-rs Project Developers"]
1010
edition = "2021"
1111
keywords = ["gtk", "gtk3", "gtk-rs", "gnome", "GUI"]

0 commit comments

Comments
 (0)